Hey! Sup.
I was trying to do a HealthBar with a particle effect when get damage or heal.
But somehow, i recive a error:
Players.vitorhinode1234.PlayerGui.UI.StaminaAndLife.Heath.HealthBar.Display:16: attempt to index number with 'Changed'
and maybe this dont will be the last error.
Can you guys help me?
The script:
local health = game.ReplicatedStorage.health
local player = game.Players.LocalPlayer
local maxHealth = player.Character:WaitForChild("Humanoid").MaxHealth
local Humanoid = player.Character:WaitForChild("Humanoid")
local Detector = game.ReplicatedStorage.health
local HealthValue = Detector.Value
health.Changed:Connect(function()
script.Parent.Size = UDim2.new(health.Value/maxHealth,0,1,0)
script.Parent.Parent.TextLabel.Text = health.Value..' / '..maxHealth
Detector.Value.Changed:Connect(function(new)
if HealthValue < new then
script.Parent.Parent.Heal.Enabled=true
wait(1)
script.Parent.Parent.Heal.Enabled=false
else
script.Parent.Parent.Blood.Enabled=true
wait(1)
script.Parent.Parent.Blood.Enabled=false
end
HealthValue = new
end)
end)
script.Parent.Size = UDim2.new(health.Value/maxHealth,0,1,0)
script.Parent.Parent.TextLabel.Text = health.Value..' / '..maxHealth
Thank you <3
Also, iām using a module for make the particles work in the GUI.