I don't know if this would work, but you maybe could update what humanoid we are listening to, as XAXA said.
fade = script.Parent
fadeGoal = 0
fadeRate = 0.01
function updateFade()
local current = fade.BackgroundTransparency
if current < fadeGoal then
fade.BackgroundTransparency = math.min(fadeGoal,current+fadeRate)
elseif current > fadeGoal then
fade.BackgroundTransparency = math.max(fadeGoal,current-fadeRate)
else
fade.BackgroundTransparency = fadeGoal
end
end
player = game.Players.LocalPlayer
character = player.Character or player.CharacterAdded:wait()
humanoid = player.Character:WaitForChild("Humanoid")
rs = game:GetService("RunService")
fadeGoal = 1
function newhumanoid()
humanoid.Died:connect(function ()
wait(1)
fadeGoal = 0
player.CharacterAdded:wait()
fadeGoal = 1
newhumanoid()
end)
end
rs.RenderStepped:connect(updateFade)
fade.Visible = true
Otherwise, if this did not work, we could just reset the script.
fade = script.Parent
fadeGoal = 0
fadeRate = 0.01
function updateFade()
local current = fade.BackgroundTransparency
if current < fadeGoal then
fade.BackgroundTransparency = math.min(fadeGoal,current+fadeRate)
elseif current > fadeGoal then
fade.BackgroundTransparency = math.max(fadeGoal,current-fadeRate)
else
fade.BackgroundTransparency = fadeGoal
end
end
player = game.Players.LocalPlayer
character = player.Character or player.CharacterAdded:wait()
humanoid = player.Character:WaitForChild("Humanoid")
rs = game:GetService("RunService")
fadeGoal = 1
humanoid.Died:connect(function ()
wait(1)
fadeGoal = 0
player.CharacterAdded:wait()
fadeGoal = 1
script:Clone().Parent = script.Parent
script:Destroy()
end)
rs.RenderStepped:connect(updateFade)
fade.Visible = true
3 comments
I dont know much about scripting but it doesnt look like its looping, you may need to figure out how to loop it.
A new humanoid is made every time the player dies. You must listen to CharacterAdded, get the humanoid from that new character, and connect to the humanoid's Died event.
@XAXA I don't understand, that's the exact reason humanoid = player.Character:WaitForChild("Humanoid") , to always wait for the new humanoid