this is my script, please help?
game:WaitForChild("Players") wait(1) game.Players.LocalPlayer.Character.Humanoid.Changed:connect(function() local health = game.Players.LocalPlayer.Character.Humanoid.Health local maxHealth = game.Players.LocalPlayer.Character.Humanoid.MaxHealth local size = script.Parent.Size wait(0.1) script.Parent.Text = health script.Parent.Parent.Size = UDim2.new(health / maxHealth,0,0,24) end)
Mk, so here's what I think, I think it's not a problem in the script, it's a problem in the GUI. Assuming the health bar displays your health properly and updates itself, I think you didn't put the health bar frame inside another frame. When you say
script.Parent.Parent.Size = UDim2.new(health/maxHealh,0,0,24)
then it does a health bar across the whole screen because it's scaling the frame across it's parent. To sum it up, to fix it, you need to make another frame in the same screen GUI and put the frame you want to scale inside of it. This new frame needs to be about the size you want the health bar to be and move the scaling frame onto it. If it still scales off a little bit then just do something like
script.Parent.Parent.Size = UDim2.new((health/maxHealth)*0.95,0,0,24)
to make it a little bit shorter. Change 0.95 and test it over and over again until it's the right size.