every time i take damage or heal it works on first
after dying and respawning, it didn’t work
how i can make this work?
and also here’s the script(its local script):
local tweenService = game:GetService("TweenService")
local text = script.Parent.HealthText
local nameText = script.Parent.HealthName
local plr = game:GetService("Players").LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local hum = character:WaitForChild("Humanoid")
local oldHealth = hum.Health
function Damaged()
text.TextColor3 = Color3.fromRGB(210,0,0)
nameText.TextColor3 = Color3.fromRGB(210,0,0)
wait(0)
local textColorChange = tweenService:Create(text, TweenInfo.new(0.25, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut), {TextColor3 = Color3.fromRGB(0, 255, 0)})
textColorChange:Play()
local nameColorChange = tweenService:Create(nameText, TweenInfo.new(0.25, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut), {TextColor3 = Color3.fromRGB(0, 255, 0)})
nameColorChange:Play()
end
function Healed()
text.TextColor3 = Color3.fromRGB(200,255,0)
nameText.TextColor3 = Color3.fromRGB(200,255,0)
wait(0)
local textColorChange = tweenService:Create(text, TweenInfo.new(0.25, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut), {TextColor3 = Color3.fromRGB(0, 255, 0)})
textColorChange:Play()
local nameColorChange = tweenService:Create(nameText, TweenInfo.new(0.25, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut), {TextColor3 = Color3.fromRGB(0, 255, 0)})
nameColorChange:Play()
end
hum:GetPropertyChangedSignal("Health"):Connect(function()
if hum.Health < oldHealth then
Damaged()
print("Damaged")
else
Healed()
print("Healed")
end
oldHealth = hum.Health
end)