Hey,
I'm trying to create a menu that appears once someone dies. However I'm getting this error:
[ERROR] addons/addonname/lua/autorun/sh_screen.lua:9: attempt to call field 'AddNetworkString' (a nil value)
1. unknown - addons/addonname/lua/autorun/sh_screen.lua:9
Here's my code:
util.AddNetworkString("OpenScreen")
function FirstJoin(ply)
net.Start("OpenScreen")
net.Send(ply)
end
hook.Add("PlayerSpawn", "uniquename", FirstJoin)
if CLIENT then
net.Receive("OpenScreen", function()
local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 0,0 )
DermaPanel:SetSize( 500, 400 )
DermaPanel:SetTitle( "Death Screen" )
DermaPanel:SetVisible( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()
DermaPanel:Center()
end)
end
Sorry if this is an easy fix but I can't seem to find the error. The file name = "sh_screen.lua".
Thanks
where is the code running? client or server?
It's running locally on "Start New Game", i've tried it on "Single Player" and with a multiple player option.
Sorry if thats not what you were asking.
either wrap it all inside of a if (SERVER) then ... else ... end or have two different files, one for client and one for server.
Thank You! Can't believe it was that easy.
thats why i asked if clientside or serverside. you were executing AddNetworkString on the client AND server. the client cant do anything with that
Makes sense. I thought shared would handle it, but obviously I still havent got the grasp of the different types yet. Thanks anyway
Shared runs the code on both sides. Which is fine if you seperate the serverside and clientside part with if statements (if SERVER / if CLIENT) but if its out of a if statement, it will run on both sides. Which again, works with shared functions. But not client or server side only
Sorry, you need to Log In to post a reply to this thread.