Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Battery script not working? [ NEED HELP ]

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

✓ Accepted answer
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

This discussion is preserved as it was. New answers, comments, and votes are closed.