Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 3 years ago
Edited by JesseSong 3 years ago

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

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

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)
0
Thank you very much! nohidas 7 — 3y
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! 2Loos 168 — 3y
Ad

Answer this question