Need Spawn Help

Hello Facepunch ,

I’ve been working on initial spawn on my server…I want Citizens to spawn in a certain space , i get no errors but doesen’t work , anyone able to fix this for me ? I’d be greatful


if (SERVER) then
 
util.AddNetworkString("NewSpawnPos")
 
net.Receive( "NewSpawnPos", function( len, ply )
 
if ply:Team() == TEAM_CITIZEN then
 
ply:SetPos( Vector( -349.285858, -1624.427612, 126.031250 ), Angle( 8.530765, 148.240250, 0.000000 ))
 
end
 
end )
 
hook.Add("InitialPlayerSpawn", "Initial.NewSpawnPoint", function(ply)
 
net.Start("NetSpawnPos")
net.SendToServer()
 
end )
 
 
end -- End of Serverside.

It’s all located in lua/autorun

Thanks in advance

Don’t do that… You’ve just created a script that could be easliy exploited… If the player manage to open a clientsided script, then they can call

to teleport themself to spawn whenever they want. Remember to never trust the client and always create checks to see if the client is lying to avoid exploits. Also don’t use network messages for that as everything is done serverside.

Why are you using the net library at all when all the functions there are serverside? Just do



hook.Add("InitialPlayerSpawn", "Initial.NewSpawnPoint", function(ply)
    if ply:Team() == TEAM_CITIZEN then
        ply:SetPos( Vector( -349.285858, -1624.427612, 126.031250 ) )
    end
end )