No player respawns after intial spawn (One life mod)

Hey there guys, I have little to no knowledge of coding, and I was wondering if any of you guys knew if it was possible to make it to where after the player dies, they cannot respawn - either through them being forcefully booted from the game/server or it just won’t let them respawn after they die. I’ve tried looking for an addon/LUA code for it but I can’t seem to find anything.

Thanks in advance!

You should explain a bit more what you’re trying to do or the issue you’re having

These should help however:

Thank you. I want to make it to where if I’m playing in Sandbox mode (Either in Single Player or Hosting a Multiplayer server) that after a player dies once, they are either kicked from the game or they just can’t spawn again. I was Googling it and I found this article, and I tried to copy the code and put it in the lua autrorun folder along with trying to attach it at the end of several other autorun codes, but of course it didn’t work - I shouldn’t have expected it to. And for player death think, is there some kind of autorun or basic lua file script somewhere when I can just change the return value to false so respawning won’t work anymore? I can’t seem to find where it is if there is one.

Sorry about all this, I’m no coder, I’m just trying to mess around with something in Gmod Sandbox is all.

You could use the PlayerDeath hook which is called when someone dies then do victim:Kick(), the wiki example should help you understand this

The slightly more complicated route would be assign a variable to each player which stores a number, reduce that number when a player dies then kick then when it’s below or equal to 0

‘return false’ instead PlayerDeathThink should prevent them from clicking to respawn, which is in sandbox by default

Try it yourself and come back if you don’t understand it, I’ll write out an example for you

This simple one-liner works for me-

hook.Add( 'PlayerDeathThink', 'NoRespawn', function(ply) return false end )

From the wiki: “Overwriting this function (PlayerDeathThink) will prevent players from respawning by pressing space or clicking.” (Note that using a hook doesn’t actually overwrite the entire function, it just gets called whenever the PlayerDeathThink function is used, and returning a value for this specific hook (true or false) overrides it, meaning the players cannot respawn. (I haven’t tested if it’s actually possible to respawn in different ways however, like with console commands or something)

Or, if you wanted them kicked, you could do:

hook.Add( 'PlayerDeathThink', 'NoRespawn', function(ply) ply:Kick( 'You died!' ) end )

This one uses the variable ‘ply’ which is returned from the PlayerDeathThink function, so you could use it to kick the player!
Sorry for spoonfeeding, but you seem to have already tried a lot…

Awesome, thank you. This is just what I needed. I appreciate the help from both you and Niandra. Thanks a lot!