Hello! I have an error in my code and I don’t know how to fix it, could someone please help me.
Health localscript:
local player = game.Players.LocalPlayer
while wait() do
script.Parent.Size = UDim2.new(0, (player.Character:WaitForChild("Humanoid").Health.."/"..(player.Character:WaitForChild("Humanoid").MaxHealth*275),.035,0))
script.Parent.Parent.Indicator.Text = "Health ".. math.floor(player.Character:WaitForChild("Humanoid").Health).."/"..(player.Character:WaitForChild("Humanoid").MaxHealth)
end
You also could make a Local script inside of “Health” and try
local health = game.ReplicatedStorage.health
local player = game.Players.LocalPlayer
while wait() do
health.Value = player.Character:WaitForChild("Humanoid").Health
end
Then You move into Replicated Storage, and add in a IntValue.
I’m wondering why you’re changing the Offset Properties & not the Size , there’s another simple way to do it and here’s an example:
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Frame = script.Parent
Humanoid.HealthChanged:Connect(function()
local Difference = Humanoid.Health / Humanoid.MaxHealth
Frame.Size = UDim2.new(Difference, 0, .035, 0)
Frame.Parent.Indicator.Text = "Health "..math.floor(player.Character:WaitForChild("Humanoid").Health).."/"..(player.Character:WaitForChild("Humanoid").MaxHealth)
end)
You also could make a Local script inside of “Health” and try
local health = game.ReplicatedStorage.health
local player = game.Players.LocalPlayer
while wait() do
health.Value = player.Character:WaitForChild("Humanoid").Health
end
Then You move into Replicated Storage, and add in a IntValue.
It worked! thanks you a lot!
As a last question, how could I adjust the “.35” does not change in size, it also changes size and becomes much smaller ingame
I don’t think I understood your question right, are you wanting to change the Y Size Property whenever a Player takes damage? (Or do you want it to not change whenever a Player takes damage)
Ooooh I see my bad, I think you can just set the Y Size property equal to the size of the Health Overlay’s Y Size, so:
Frame.Size = Udim2.new(0, (Difference*275), --Whatever the Gray's Frame Size Y is, 0)
(Or you can just guess how far to make the Y size property whatever works really lol, we should also probably talk in a PM so that we’re not spamming this post)