Oxygen bar is scaling weirdly

I have an oxygen bar and the bar fit the frame properly but now its not
It should look like this: Screen Shot 2021-10-16 at 2.14.40 PM
But instead it looks like this:

There’s a localscript inside the oxygen screengui that adjusts the size:

local player = game.Players.LocalPlayer
local Hum = player.Character:WaitForChild("Humanoid")
local background = script.Parent
local Bar = background:WaitForChild("Bar")
local OxygenText = background:WaitForChild("OxygenText")

OxygenText.Size = UDim2.new(1,0,1,0)

local oxyValue = player:WaitForChild("OxygenValue")

while wait(0.3) do
	Bar:TweenSize(UDim2.new(player.OxygenValue.Value/1000,0,1,0), "Out", "Quad", 0.3)
	OxygenText.Text = player.OxygenValue.Value.."/1000"
	if OxygenText.Text == "0/1000" then
		Hum.Health = 0

Check the parent of the frame or check the original size, one must be wrong.

I adjusted all the sizes and they all didn’t work so I just decided to put the script back how it was

Yeah like SOTR said, check the parent of that bar… what probably is happening is that the parent of it is a ScreenGui object, so when you do the line of code:

OxygenText.Size = UDim2.new(1,0,1,0)

You’re basically telling it to hav an X and Y scale of 1. So, it will be the same size of whatever parent it is. I’m guessing the parent is the ScreenGui because that has the size of the screen.

I recommend to fix this, using a dummy frame, that will be the size of the bar when it’s at its max length, and that frame will be the parent of the actual oxygen bar.

i actually fixed it myself i had the bar set up wrong and everything was parented to the screengui but the background should have had everything else in it so i fixed it like this:
Screen Shot 2021-10-16 at 8.47.22 PM

Yeah its cause everything was parented to screenGui. Like this, the size is now limited to Background. Great :slight_smile:

1 Like