• Null Entity
    3 replies, posted
Hello! I am new to LUA and need help with this. I am trying to setup teams and I keep getting this error. [ULib] lua/team_setup.lua:24: Tried to use a NULL entity!   1. SetTeam - [C]:-1    2. fn - lua/team_setup.lua:24     3. unknown - lua/ulib/shared/hook.lua:109 Here is the code local meta = FindMetaTable ( "Player" ) local teams = {} teams[0] = { name = "Red" , colour = Vector ( 1.0 , 0 , 0 ) } teams[1] = { name = "Blue" , color = Vector ( 0 , 0 , 1.0 ) } hook.Add( "PlayerSay" , "ChangeTeam" , function( pl , text ) if  ( text ==  "/Red" and IsValid( pl ) ) then print ( "You changed team!" ) pl.SetTeam( "Red" ) else if  ( text ==  "/Blue" and IsValid( pl )  ) then print ( "You changed team!" ) pl.SetTeam( "Blue" ) end end  end ) Thank you!
You need to use pl:SetTeam("Color") instead of pl.SetTeam("Color"). Or, pl.SetTeam(pl, "Color") The difference is that when you use the colon, it calls the function WITH that object as the first argument. Using the period just gives a reference to the function so you'd have to explicitly include the object in there as well.
Colons not dots. Also might i recommend renaming your hook to something better so other addons don't conflict.
Thank you both! I accepted a random one but gave a coin to another one. Thank you for your time!
Sorry, you need to Log In to post a reply to this thread.