So I thought it would be cool if I made an animated death screen and it tweens into the screen when you die. It works, but when you die it plays twice.
local tweenService = game:GetService("TweenService")
local db = false
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Died:Connect(function()
if db == false then
db = true
local tweenInfo = TweenInfo.new(
2,
Enum.EasingStyle.Quart,
Enum.EasingDirection.InOut,
1,
false,
0
)
local Ui1 = {
Rotation = 0;
Position = UDim2.new(0, 0,0.275, 0)
}
local Ui2 = {
Rotation = 0;
Position = UDim2.new(0, 0,0.475, 0)
}
local Ui3 = {
Rotation = 0;
Position = UDim2.new(0, 0,0.546, 0)
}
local t1 = tweenService:Create(script.Parent:WaitForChild("DeathMessage"),tweenInfo,Ui1)
local t2 = tweenService:Create(script.Parent:WaitForChild("RespawnTime"),tweenInfo,Ui2)
local t3 = tweenService:Create(script.Parent:WaitForChild("tip"),tweenInfo,Ui3)
t1:Play()
t2:Play()
t3:Play()
wait(1)
db = false
end
end)
