how do i make this code only run for 1 player?

local function FirstSpawn( ply )
	RunConsoleCommand( "w_2_sp" ) 
hook.Add( "PlayerInitialSpawn", "playerInitialSpawn", FirstSpawn )

how do i make that code run only for the guy who have spawned and not everyone else?


ply:ConCommand( "w_2_sp
" )

what does the

well thx :slight_smile: it worked

is a newline. game.ConsoleCommand still requires it to be the final character, I think, and I just put it in pl:ConCommand out of habit from that.

oh, thanks alot :slight_smile:

You might want to rethink your method as any player can still enter that command manually. It’s also bad practice to run lua functions via a console command, where it can be done in code only.

ply:ConCommand doesn’t require a newline character in the end. Console commands also happen to be the only way to send data to the server.

Datastreams (ew) :v:

Datastream also uses console commands to send the data.