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

How do you make this script turn black, and fade away before they respawn?

Asked by 10 years ago

I tried to work this, but it wouldn't work, could someone show me how you would make a player turn black and fade away, when they die, but like right before they respawn they fade away?

game.Players.PlayerAdded:connect(function(player)

player.CharacterAdded:connect(function(character)

character:WaitForChild("Humanoid").Died:connect(function()

print (player.Name .. " has died...")

end)

end)

end)

1 answer

Log in to vote
0
Answered by
Tkdriverx 514 Moderation Voter
10 years ago

What do you mean "turn black"? Do you mean their body parts turn black? If so:

game.Players.PlayerAdded:connect(function(player)
    Delay(0, function() -- This prevents a yield from pausing the script (In this case, the WaitForChild)
        player.CharacterAdded:connect(function(character)
            local humanoid = character:WaitForChild("Humanoid")

            humanoid.Died:connect(function()
                print (player.Name .. " has died...")

                for _, part in pairs(character:children()) do
                    if part:isA("BasePart") then
                        part.BrickColor = BrickColor.new("Black")

                        Delay(2, function() -- Yield protection; runs 2 seconds later.
                            for i = 0, 1, 0.1 do
                                part.Transparency = i
                                wait()
                            end
                        end
                    end
                end
            end)
        end)
    end)
end)
0
Yes, turn black and fade away. Wrongmistake 0 — 10y
0
Oh, and fade away? Standby. Tkdriverx 514 — 10y
0
Edited. Tkdriverx 514 — 10y
Ad

Answer this question