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
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.
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).
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
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.