I have this gui tween play every time a player dies. But. it only works after the player has died once. I tried looking around the forum but I couldn’t find an exact solution.
I placed this local script in the StarterPlayerScripts because if I placed it in the SCS it will only work halfway through the tween since the character and the scripts inside of it reset on spawn.
The variables in the code snippet are all defined and there are no errors in the output. Any help would be greatly appreciated.
local function deathFade()
deathFadeTween:Play()
wait(1.5)
whiteBar:TweenSize(UDim2.new(0.2, 0, 0, 2))
wait(1)
deathTextTween:Play()
wait(3)
deathTextTween1:Play()
wait(1)
whiteBar:TweenSize(UDim2.new(0, 0, 0, 2))
wait(1.5)
deathFadeTween1:Play()
end
localHumanoid.Died:Connect(function()
deathFade()
end)
The humanoid variable is not nil anymore whenever a player respawns now, but I narrowed down the issue to the .Died event because it doesn’t want to fire after the player has died once.
I finally find a working solution.It isn’t pretty but I’ll post the code.
I needed to connect two .died events. The bottom one is for when the player first dies, then the other one triggers after the player dies more than once. I do not know why it works, but it does.