My script is simple but causes this error
[CODE]attempt to index local 'main' (a nil value)[/CODE]
My code is
[CODE]if SERVER then
util.AddNetworkString("openmenu")
hook.Add("PlayerInitialSpawn","MGLUA_PlayerInitialSpawn_Identifier",function(ply)
net.Start("openmenu")
net.Send(ply)
end)
end
if CLIENT then
net.Receive("openmenu",function()
local main = vgui.Create("DFrame")
main:SetSize(1400,400)
main:SetTitle("")
main:Center()
end)
end[/CODE]
If this is not possible using this method, please let me know if there is another way to open a menu when a player spawns.
You switched the first and second argument for the hook. The first one should be PlayerInitialSpawn. And the second should be the identifier.
[QUOTE=MelonShooter;52743061]You switched the first and second argument for the hook. The first one should be PlayerInitialSpawn. And the second should be the identifier.[/QUOTE]
I switched them around but I still got this problem, atleast the same error.
[QUOTE=RazMouze;52744823]I switched them around but I still got this problem, atleast the same error.[/QUOTE]
That may be due to the player not fully initializing and not being able to create the vgui menu.
I'd recommend perhaps putting this code clientside instead on maybe the Initialize hook and using a timer. Or check when LocalPlayer is valid and create the menu then if possible.
Sorry, you need to Log In to post a reply to this thread.