Help making combo bar

What it supposed to look like:
image

What it looks like:

image

References: You can see the bar with x combos

SCRIPT:

local maxvalue = script.Parent.MAXVALUE
local fillbackground = script.Parent.FILLBACKGROUND
local fill = fillbackground.FILLL
local runservice = game:GetService("RunService")

runservice.RenderStepped:Connect(function()
	local division = currentvalue.Value / maxvalue.Value
	fill.Size = UDim2.fromOffset(0, division)
end)
2 Likes

The issue is the size that you are setting it to.

division will be a value between 0 and 1. Because of this, I assume you want to use scale instead of offset. Additionally, you need to give it a size in the X direction instead of just saying 0

local maxvalue = script.Parent.MAXVALUE
local fillbackground = script.Parent.FILLBACKGROUND
local fill = fillbackground.FILLL
local runservice = game:GetService("RunService")

runservice.RenderStepped:Connect(function()
	local division = currentvalue.Value / maxvalue.Value
	fill.Size = UDim2.fromScale(.8, division)
end)

Also, you should look at using .Changed:Connect(function() … end) instead of using RenderStepped - it’ll be a lot more performant

2 Likes

This is what it looked like when I put that script:

image

2 Likes

Set the anchor point of the bar object to 0.5, 1

1 Like

This is what it looked like:
image

1 Like

I managed to put the right anchor point now. How can I prevent the GUI OBJECT from exceeding its backgroound?

image
image

1 Like

You need to move the position down more.
From UDim2.fromScale(.8, division), multiply division with whatever that scale is when it appears full

1 Like

Sorry what number should I multiply it too? What do you mean by “whatever scale that is”?

1 Like

Well how do you have it set up in explorer? Is the white bar a child of the black bar? If not, and its contained within the same parent, then the final height should be the height of the black bar. You can reduce it slightly if you don’t want it going all the way

Yes the white bar is parented to its background

then you don’t need to multiply it.
Just have the size as
UDim2.fromScale(1, division) and modify the anchor point until it starts at the very bottom.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.