Healthbar GUI Changes Size when testing in game

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Fix my health bar which sizes weirdly when testing it in-game.

  2. What is the issue? Include screenshots / videos if possible!
    image
    Healthbar appears out of the GUI when testing the game, it is sized correctly though when looking at it in Roblox Studio.
    image

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    My friend was making the GUI and he has no clue how to fix it. I don’t know the exact solutions he has tried, sorry. I have looked around at it and tried searching up but I cant find anything, I may not be looking close enough though.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

I simply want the healthbar to not appear outside of the GUI outline when playing the game.
Here is the code for the healthbar:

local TW = game:GetService("TweenService")

local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

local Healthbar = script.Parent

local function UpdateHealthbar()
	local health = math.clamp(Humanoid.Health / Humanoid.MaxHealth, 0, 1)
	local info = TweenInfo.new(Humanoid.Health / Humanoid.MaxHealth,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0)
	TW:Create(script.Parent,info,{Size = UDim2.fromScale(health, 1)}):Play()
end

UpdateHealthbar()

Humanoid:GetPropertyChangedSignal("Health"):Connect(UpdateHealthbar)
Humanoid:GetPropertyChangedSignal("MaxHealth"):Connect(UpdateHealthbar)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

make the sure the size/position is using scale instead of offset

Can u explain more in-depth, how do i change this?

Make offset 0 in sizes? After that’s done check again, Hope this helps

It my also be one of the scripts that’s affecting it

I’m honestly really confused because I didn’t make this GUI and my friend who did is offline, do you have discord? So we can discuss this further in there.

I’m afraid I don’t have a discord. Maybe chat in a message through DevForum?

The script seems to work fine, so I guess the error is how you adjusted the position of the Frame.

Could you possibly tell me how to fix the position of the frame?

I said it was the position, but it can also be the rotation. Tell me what is the size, position and rotation

My friend left it in the top left corner,
POS: {0, 0},{0, 0}
SIZE: {0, 153},{0, 101}
ROTATION: 0

You should use Scale, change your health bar size into {0,0},{0,0}.
Then resize it.

I think the issue was size because the size might change different devices so it doesn’t fit, so use my solution, and reply to me if does not work.

Nothing is working, I tried it and it didn’t work. I may have done it wrong or something. Do you have discord? I can add you to the baseplate so you can try and fix the GUI maybe?

1 Like

DryOfficial#2363 here my Dizzy just tell me the problem.

1 Like

TW:Create(script.Parent,info,{Size = UDim2.fromScale(health, 1)}):Play()
The problem was the size in (health, 1).
Thanks to @DryOfficial he was able to fix the problem by changing it to .25
TW:Create(script.Parent,info,{Size = UDim2.fromScale(health, .25)}):Play()

It was a simple fix I just don’t know how to script haha.

1 Like