It’s structured as a CanvasGroup, with a Frame inside of it like this, where the canvas group is the background, and the frame is the visualization bar.
However, I’m running into a major issue. The ProgressIndicator is extremely small and never reaches all the way to the edge of the CanvasGroup. I have code running in the UpdateBarGUI local script to affect its appearance. It runs on activation of a RemoteEvent.
local function GetXPRequiredForLevel(level)
return 100 * (level * 50)
end
local function updateBar(xp, level)
local required = GetXPRequiredForLevel(level)
local ratio = math.clamp((xp / required), 0, 1)
local tweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local barTween = TweenService:Create(ProgressIndicator, tweenInfo, {Size = UDim2.new(ratio, 0, 1, 0)})
barTween:Play()
end
I don’t really know what’s going on, and the size of the bar seems to change at complete random. Any help would be appreciated!
I don’t believe your progressindicator itself needs a uicorner as anything in a canvas group like for example if the canvas group had a uicorner (which it does) it will inherit.
Can you do some basic debugging? Print the xp given, level, and ratio.
Print the current size of the progress bar.
I was actually able to figure it out (I have no idea what was wrong with it, it just broke for some reason). I did some prints and all the sudden the bar started behaving.
I also fixed the xp requirement to be 100 + (level * 50). This is literally all I changed.
local function updateBar(xp, level)
local required = GetXPRequiredForLevel(level)
print("Required XP: "..required)
local ratio = math.clamp((xp / required), 0, 1)
print("Ratio: "..ratio)
print("Progress Bar absolute size (X):", ProgressBar.AbsoluteSize.X)
print("Progress Indicator absolute size (X):", ProgressIndicator.AbsoluteSize.X)
local tweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local barTween = TweenService:Create(ProgressIndicator, tweenInfo, {Size = UDim2.new(ratio, 0, 1, 0)})
barTween:Play()
end
I’m sure this was some kind of weird datastore issue (as everything has been lately).