Someone please tell my why this localscript breaks whenever I reset/die tyvm (Located in starterplayerscripts)
local player = game.Players.LocalPlayer
wait(3)
local previousvalue = 100
local gui = Instance.new("ScreenGui", player.PlayerGui)
local frame = Instance.new("Frame", gui)
gui.ResetOnSpawn = false
gui.Name = "Red"
frame.Size = UDim2.new(0, 10000, 0, 10000)
frame.Position = UDim2.new(0.5, -5000, 0.5, -5000)
frame.BorderSizePixel = 0
frame.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
frame.BackgroundTransparency = 1
player.Character.Humanoid.HealthChanged:Connect(function()
if player.Character.Humanoid.Health < previousvalue then
if player.Character.Humanoid.Health > 75 then
frame.BackgroundTransparency = 0.75
while frame.BackgroundTransparency < 1 and wait(0.01) do
frame.BackgroundTransparency = frame.BackgroundTransparency + 0.01
end
else
if player.Character.Humanoid.Health > 50 then
frame.BackgroundTransparency = 0.50
while frame.BackgroundTransparency < 1 and wait(0.01) do
frame.BackgroundTransparency = frame.BackgroundTransparency + 0.01
end
else
if player.Character.Humanoid.Health > 25 then
frame.BackgroundTransparency = 0.25
while frame.BackgroundTransparency < 1 and wait(0.01) do
frame.BackgroundTransparency = frame.BackgroundTransparency + 0.01
end
else
if player.Character.Humanoid.Health > 0 then
frame.BackgroundTransparency = 0
while frame.BackgroundTransparency < 1 and wait(0.01) do
frame.BackgroundTransparency = frame.BackgroundTransparency + 0.01
end
else
frame.BackgroundTransparency = 0
while frame.BackgroundTransparency < 1 and wait(0.1) do
frame.BackgroundTransparency = frame.BackgroundTransparency + 0.01
end
end
end
end
end
end
end)
while wait() do
previousvalue = player.Character.Humanoid.Health
end
