I have a gui that fades in upon death. It use to be in a "while true do" but I watned to remove it since if I wait too long, it'll start looping. How would I fix this?
local spp = script.Parent.Parent.Parent.Parent.Character.Humanoid
local sp = script.Parent
if spp.Health == 0 then
wait(2.5)
sp.BackgroundTransparency= 0.8
wait(.1)
sp.BackgroundTransparency= 0.7
wait(.1)
sp.BackgroundTransparency= 0.6
wait(.1)
sp.BackgroundTransparency= 0.5
wait(.1)
sp.BackgroundTransparency= 0.4
wait(.1)
sp.BackgroundTransparency= 0.3
wait(.1)
sp.BackgroundTransparency= 0.2
wait(.1)
sp.BackgroundTransparency= 0.1
wait(.1)
sp.BackgroundTransparency= 0
end
--while true do is removed, no longer works

2 comments
Wouldn't the Died event be best since that way you're not checking over and over, 30 times a seconds?
Yes, the Died event would be preferable. If this is only being done for a single thing, though, it isn't any work at all to just check Health, so it's not harmlful