Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Battery script not working? [ NEED HELP ]

Asked by 10 years ago

So, this battery is supposed to represent health, but it re sizes for some reason. I don't know if I typed n the size wrong in the script, I don't know. Please look at these pictures to help answer this problem.

wait(.3)

Par=script.Parent.Parent.Parent.Parent.Parent
while true do
    wait()
    Heal=Par.Character.Humanoid
    wait()
    script.Parent.Parent.Health.Value=Heal.Health
    script.Parent.Parent.Total.Value=Heal.MaxHealth
    Min=150/Heal.MaxHealth
    script.Parent.Size=UDim2.new(0,Min*Heal.Health,1,0) 
    end

REALLY LOOK AT THESE PICTURES TO HELP ANSWER THE PROBLEM!

1 answer

Log in to vote
0
Answered by 10 years ago
while true do --Ugly
HUMANOID.Changed:connect(function() --Instead, use this
end)
UDim2.new(health/maxhealth,0,1,0)--Use the scale instead of offset

I will explain why you cannot use offset. Offset relies on nothing, while scale relies on the size of the screen it is in.

UDim2.new(1,0,1,0)--Covers the whole screen
UDim2.new(0,1000,0,1000)--Covers SOME of the screens

The same effect happens under a frame,imagelabel,etc.

Example.Parent = frame
Example.Size = UDim2.new(1,0,1,0) --Covers the whole frame
Ad

Answer this question