I've been trying to do some basic gui setting up with derma, the problem is that I can't get the script to run only on the client, and thus I keep getting an error that says vgui doesn't exist, because it can't be ran on the server. I have tried making a folder in autorun called client, but that didn't work, also neither did putting the code in cl_init. The code is very basic and just creates a frame, it was just a test so I could begin making more complicated things, anyway, can someone tell me how to make a file run on the client only?
Here's a quick derma example, take a look at the wiki next time you get stuck. They have all the derma controls so you can see what you need or what you're doing wrong but here goes.
[lua]
concommand.Add("DermaExample",function()
local main = vgui.Create("DFrame")
main:Center()
main:MakePopup()
main:SetSize(500,500)
main:SetTitle("Example Derma")
end)
[/lua]
Try using:
[lua]
if CLIENT then
--Derma Stuff Here
end
[/lua]
If it's running clientside or in a shared environment, it will work. If it's running serverside, then it will simply do nothing, and you'll need to move the code somewhere that [b]is[/b] clientside.
[editline]edit:[/editline]
Putting a script in lua/autorun/client [i]should[/i] run it clientside. If you need to check put this in your script and test it in [b]Single Player[/b]:
[lua]
if CLIENT then print("The script is running clientside!") elseif SERVER then print("The script is running serverside!") end
[/lua]
If it prints both of the messages, the script is [b]shared[/b].
Sorry, you need to Log In to post a reply to this thread.