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

Death Script: Don't Respawn automatically. Press button to respawn. Can I get help?

Asked by 7 years ago

Hello! I am attempting to make an RP game for my Roleplay community and want to make a script we would refer to as a Death Script. Basically when you die you will go into a ragdoll then if you press 'R' it will respawn and 'E' will revive (Spawn you where you died). Please could I get help if it is possible. I have a ragdoll script when you die but I would prefer it to be in the same script. So far I have:

local mouse = game.Players.LocalPlayer:GetMouse()

game.Players.CharacterAutoLoads = false

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        local humanoid = character:FindFirstChild("Humanoid")
        if humanoid then
            humanoid.Died:connect(function()
                mouse.KeyDown:connect(function(key)
                    key = string.lower(key)
                    if string.byte(key) == "r" then
                        player.LoadCharacter()
                    end
                end)
            end)
        end
    end)
    player.LoadCharacter()
end)

The script I started with was one I found on the Wiki which delays the respawn.

local respawnDelay = 5

game.Players.CharacterAutoLoads = false

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        -- find the humanoid, and detect when it dies
        local humanoid = character:FindFirstChild("Humanoid")
        if humanoid then
            humanoid.Died:connect(function()
                wait(respawnDelay)
                player:LoadCharacter()
            end)
        end
    end)
    player:LoadCharacter() -- load the character for the first time
end)

The problem with the edited script I am having is it respawns you after 5 seconds automatically. I also dont have a revive in it yet.

Many Thanks. Ethan

1 answer

Log in to vote
0
Answered by 4 years ago

I have the answer! if you don't want to read this, then check out the video I made for you! https://youtu.be/7-XFGmjDH8c Now, Here is how you do it. if you have not already go into explorer (in view tab) then, click on players. not starter players, players. next click properties, You should see a tab that says "Respawn Time". Last, Change it to whatever you want! For more explanation visit: https://youtu.be/7-XFGmjDH8c

Ad

Answer this question