What is the problem with the second tween? the first tween worked, but the second one just won't work. Even if I remove the first tween, it still won't work. Is there something wrong?
It's basically a health detector, so if a player lose some, the gui color changes, but I want the color change to be smooth. So I used tween, the first tween worked, but the second one didn't, I don't know why
player = game.Players.LocalPlayer
healthcolor = script.Parent.Frame.ImageLabel
textbox = script.Parent.Frame.ImageLabel.TextBox
local TweenService = game:GetService('TweenService')
local tweeninfo = TweenInfo.new(0.5, Enum.EasingStyle.Linear)
player.CharacterAdded:connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
humanoid.HealthChanged:connect(function(health)
if health >= 81 and health <=100 then
healthcolor.ImageColor3 = Color3.new(0,255,0)
textbox.Text = 5
end
if health >= 61 and health <=80 then
healthcolor.ImageColor3 = Color3.new(0,255,0)
textbox.Text = 4
end
if health >= 41 and health <=60 then
healthcolor.ImageColor3 = Color3.new(0,255,0)
local tween = TweenService:Create(healthcolor, tweeninfo,
{ImageColor3 = Color3.fromRGB(255,255, 0)})
tween:Play()
wait(0.5)
healthcolor.ImageColor3 = Color3.new(255,255,0)
textbox.Text = 3
end
if health >= 21 and health <=40 then
healthcolor.ImageColor3 = Color3.new(255,255,0)
textbox.Text = 2
end
if health >= 1 and health <=20 then
healthcolor.ImageColor3 = Color3.new(255,255,0)
local tween = TweenService:Create(healthcolor, tweeninfo,
{ImageColor3 = Color3.fromRGB(255,0, 0)})
tween:Play()
wait(0.5)
healthcolor.ImageColor3 = Color3.new(255,0,0)
textbox.Text = 1
while true do
textbox.TextColor3 = Color3.new(255,0,0)
wait(0.5)
textbox.TextColor3 = Color3.new(0,0,0)
wait(0.5)
end
end
if health == 0 then
healthcolor.ImageColor3 = Color3.new(255,0,0)
textbox.Text = 0
textbox.TextColor3 = Color3.new(255,0,0)
end
end)
end)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)

5 comments
can you show the whole thing? when does the code run?
done!
You might be advised to use elseif.
I don't know if elseif will have the same effect tho, let's just not focus on that.
Anyways, I'm going to sleep. If someone answered my question while I was asleep. thanks a lot!