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

How can I make this code repeat every time a player dies?

Asked by 4 years ago

I've tried this but it didn't work.

while wait(1) do
    local player = game:GetService("Players").LocalPlayer
    local humanoid  = player.Character.Humanoid

    if humanoid.Health == 0 then
        wait(6)
        mouse.KeyDown:Connect(function(key)
            if key == "e" then
                if mouse.Target then
                    humanoidRoot.CFrame = CFrame.new(mouse.Hit.x,mouse.Hit.y + 5,mouse.Hit.z)
                end
            end
        end)
    end
end
1
humanoid.Died:Connect(function() greatneil80 2647 — 4y
0
That didn't work osamayousef123 11 — 4y
0
if Died doesn't work, myb HealthChanged SerpentineKing 3885 — 4y
0
Doesn't that work all the time even if the player dies and even without the humanoid.Health ==0? roussimoff 17 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

I would reckon highering the spawn location and putting a block on the spawn location, and the putting:

script.Parent.Touched:Connect(function(hit)
-- code here
end)
0
I will try that osamayousef123 11 — 4y
Ad

Answer this question