Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is there a script to make a player rejoin upon death?

I wrote this code today but have recently decided I would the player to rejoin the place instead of be kicked.

I do not know how to do this.

Code I wrote for kick on death:

Message = "Table boss has wrecked you."

game.Players.PlayerAdded:connect(function(plyr)
	
	
	repeat wait() until plyr.Character ~= nil
	repeat wait() until plyr.Character:FindFirstChild("Humanoid") ~= nil
	
	
	
	plyr.Character.Humanoid.Died:connect(function()
		plyr:Kick(Message)
	end)
	
end)

If anybody could help it'd be greatly appreciated.

Note: Not sure if it will matter but the place that it needs to rejoin is a place and not a starter-place.

-Nohidas :D

1 answer

✓ Accepted answer

I'm assuming you are trying to rejoin to a place then you can just use game:GetService("TeleportService")

local TeleportService = game:GetService("TeleportService")
local placeId = -- your place id here

game.Players.PlayerAdded:Connect(function(plyr)        
    repeat wait() until plyr.Character ~= nil
    repeat wait() until plyr.Character:FindFirstChild("Humanoid")

    plyr.Character.Humanoid.Died:Connect(function()

        -- do whatever you want before teleporting the player

        TeleportService:Teleport(placeId, plyr)
    end)
end)

2 comments

0

Thank you very much!

0

Wow, I never knew teleport service worked for your own game! So that's how rejoin commands work on admin loaders! Thank you, upvoted!

This discussion is preserved as it was. New answers, comments, and votes are closed.