How to make it so the respawn command give you a crowbar

I have started a gmod server for deathrun and I have the respawn command from ulx what works fine but when I use it you don’t respawn with a crowbar can anyone help me thanks

ply:Give(“weapon_crowbar”)

That is the code what I have do I just add it to the bottom of the code?

local CATEGORY_NAME = “Deathrun”

function ulx.respawn( calling_ply, target_ply )
if not target_ply:Alive() then
target_ply:Spawn()
ulx.fancyLogAdmin( calling_ply, true, “#A respawned #T”, target_ply )
end
end

local respawn = ulx.command( CATEGORY_NAME, “ulx respawn”, ulx.respawn, “!respawn”, true )
respawn:addParam{ type=ULib.cmds.PlayerArg }
respawn:defaultAccess( ULib.ACCESS_ADMIN )
respawn:help( “Respawns a player” )

Copypaste this line:
target_ply:Spawn()

( to the line below )

and change it so it looks like the post above yours, except for the variable name (ply).

add ply:Give(“weapon_crowbar”) just breaks the command so i can’t use it ingame

target_ply:Give(“weapon_crowbar”)

underneath

target_ply:Spawn()

I have done it now but still breaks the command here is the new code
local CATEGORY_NAME = “Deathrun”

function ulx.respawn( calling_ply, target_ply )
if not target_ply:Alive() then
ply:Give(“weapon_crowbar”)
target_ply:Spawn()
ulx.fancyLogAdmin( calling_ply, true, “#A respawned #T”, target_ply )
end
end

local respawn = ulx.command( CATEGORY_NAME, “ulx respawn”, ulx.respawn, “!respawn”, true )
respawn:addParam{ type=ULib.cmds.PlayerArg }
respawn:defaultAccess( ULib.ACCESS_ADMIN )
respawn:help( “Respawns a player” )

What is the error you’re getting?

What you are doing is if not the target is alive then you give them a crowbar, THEN you spawn them.

So, you need to spawn them, then give them a crowbar.

The error what i’'m getting just by adding ply:give (“weapon_crowbar”) it just breaks the whole command so I can’t use it and i have checked the logs and console and i’m not getting no lua errors

It’s target_ply, not ply. And do it after running target_ply:Spawn()


function ulx.respawn( calling_ply, target_ply )
if not target_ply:Alive() then
target_ply:Spawn()
target_ply:Give("weapon_crowbar")

ulx.fancyLogAdmin( calling_ply, true, "#A respawned #T", target_ply )	
end
end

local respawn = ulx.command( CATEGORY_NAME, "ulx respawn", ulx.respawn, "!respawn", true )
respawn:addParam{ type=ULib.cmds.PlayerArg }
respawn:defaultAccess( ULib.ACCESS_ADMIN )
respawn:help( "Respawns a player" )

[lua]function ulx.respawn( calling_ply, target_ply )
if not target_ply:Alive() then
target_ply:Spawn()
target_ply:Give(“weapon_crowbar”)

	ulx.fancyLogAdmin( calling_ply, true, "#A respawned #T", target_ply )	
end

end

local respawn = ulx.command( CATEGORY_NAME, “ulx respawn”, ulx.respawn, “!respawn”, true )
respawn:addParam{ type=ULib.cmds.PlayerArg }
respawn:defaultAccess( ULib.ACCESS_ADMIN )
respawn:help( “Respawns a player” )
[/lua]

Sorry, I needed to add some tabulation, that code was really hurting my eyes…