Bars out of frames

so in my game im making a character hud with bars for values, in studio its scaled and everything but in game the bars are all out of the frames, i thought it might had been a gui issue but then i disabled the scripts and they stayed in place. I’ve tried everything i could think of to fix it but nothing is working

Before testing:

While in game:

Anything helps!

We can’t exactly help you if this is a script issue as you said, with no code to see. You can use the roblox “Find all / Replace All” tab and search for the GUI name to find what scripts identify it and may edit it. Using that you might find the solution to your problem but other than that, we can’t do more without anything to see.

Try using UIAspectRatioConstraint. If you don’t know how to use UIAspectRatioConstraint, there is a plugin that auto scales and inserts it inside a selected instance.

im so sorry i forgot to add the script, here is the one for the health bar. the magic bar uses the same format as this one

local Player = game.Players.LocalPlayer

pcall(function()
local data = Player.Character:WaitForChild(“Humanoid”, 120).Health/Player.Character:WaitForChild(“Humanoid”, 120).MaxHealth/1
script.Parent:WaitForChild(“HealthBar”, 120):TweenSize(UDim2.new(data, 0, 1, 0), “Out”, “Quad”, .25, true)
Player.Character:WaitForChild(“Humanoid”, 120):GetPropertyChangedSignal(“Health”):Connect(function()
local data = Player.Character:WaitForChild(“Humanoid”, 120).Health/Player.Character:WaitForChild(“Humanoid”, 120).MaxHealth/1
script.Parent:WaitForChild(“HealthBar”, 120):TweenSize(UDim2.new(data, 0, 1, 0), “Out”, “Quad”, .25, true)
end)
end)

i tried that but it still does it the only difference is it scales differently.

Do you have any errors? Also, I may have an idea of the issue, can you send a picture of the actual code (don’t copy and paste it, attach an image, I want to see it in the script itself).

Have you used any UI element or property that is currently a BETA feature? Beta features are only working in studio and not live games.

nope no errors in the output, here is the script image

for the scale type i use slice, i was reading on one forum that slice was in beta so maybe thats it??

Try printing data and seeing what it outputs.

i added print statement’s to both of the parts, it only printed off one of them which was the first one, and the value it printed was “1”

Likely has to do with the actual tweening. Tweensize is deprecated, so you should be using Tweenservice, not that I think that is the source of the problem, but a switch might be necessary in the long run. I also recommend cleaning your script up.

You should identify the GUI using playergui as well.

pcall(function()
local char = Player.Character
local hum = char:WaitForChild("Humanoid")
local data = hum.Health/hum.MaxHealth

local playerGui = player:WaitForChild("PlayerGui")
local HealthBar = --[Put the GUI that leads the healthbar, list out the frames, I don't know your GUI so I cannot do this step for you]
end)

Now that we’ve set your variables, we use Tweenservice. Tweenservice requires a goal, tweeninfo and object.

local TweenService = game:GetService("TweenService")

pcall(function()
local char = Player.Character
local hum = char:WaitForChild("Humanoid")
local data = hum.Health/hum.MaxHealth

local playerGui = player:WaitForChild("PlayerGui")
local HealthBar = --[Put the GUI that leads the healthbar, list out the frames, I don't know your GUI so I cannot do this step for you]

local goal = {}
goal.Size = UDim2.fromscale(data,1) -- You can use fromscale, since you aren't using the offset option

local Info = TweenInfo.new(.25,Enum.EasingStyle.Quad,Enum.EasingDirection.Quad)
local Tween = TweenService:Create(HealthBar,Info,goal)
Tween:Play()

hum:GetPropertyChangedSignal("Health"):Connect(function()
goal.Size = UDim2.fromscale(data,1) -- You can use fromscale, since you aren't using the offset option
local Tween = TweenService:Create(HealthBar,Info,goal)
Tween:Play()
end)
end)

This should work although I did not test. You can read more about TweenService here:

now that i applied the script u provided its not moving at all when the player is damaged i looked on the output but nothing came up, thank you for the information about what i was using before it totally went over my head to use tweenservice and not tweensize. if it helps here is how the gui is set up

the “HealthFrame” is the outline and then the “HealthBar” is the actual bar.

Let me see your script now, in full.

Nope this wouldn’t work, GUIs don’t load like that. For your healthbar do,

local HealthBar = playerGui:WaitForChild("MagiciansStatsUI"):WaitForChild("HealthFrame"):WaitForChild("HealthBar")

The reasoning behind this is GUIs need time to load since they are on the client, if you identify them instantly they won’t appear because scripts load first, then the GUIs.

that didnt do it either, i even made a print statment if it found them, it found them but yet its not moving?

Comment out the PCall function and it’s end) and see if any errors appear, if so, send them here.

yep there is an error, its coming from the highlighted line

04:41:39.727 Players.YemylaPastel.PlayerGui.MagiciansStatsUI.HealthFrame.HealthHandler:17: attempt to call a nil value - Client - HealthHandler:17

Ah ok. Change char to:

local char = player.Character or player.CharacterAdded:Wait()