Cooldown GUI sometimes tweens out of place?

I am creating a fighting game, and when the player uses a move, it places a cooldown gui on the top-right corner of the screen. The cooldown gui system works fine but there’s a small issue with it. The thing is when a move gui that’s ontop of another gui disappears, it tweens up in it’s place. Sometimes when this happens it weirdly places itself in the wrong spot. Each of these guis are about 0.060 apart on the YScale part of Udim2, and when a gui above it disappears, it subtracts 0.060 from it’s original position to tween in it’s place. I am having a hard time finding the issue and would appreciate any help solving this. (The script is handled inside a module that has 3 arguments, cooldown being self-explanatory, name being the name of the move that’s being displayed on the gui, and the player being the player so the script can access their gui.) ALSO the cooldownnumber intvalue counts how many cooldown guis there are by raising/lowering the value everytime a gui is added/removed.

module.createCooldown = function(cooldown, name, player)
	local died = false
	local gui = player.PlayerGui.Misc:WaitForChild("CooldownGUI")
	local placeholder = gui:WaitForChild("CooldownPlaceholder")
	local cooldownUI = placeholder:Clone()
	cooldownUI.Parent = gui
	local cooldownNumber = gui.GuiNumber
	cooldownUI.Name = "CooldownUI"
	cooldownUI.Position =, 0, 0.025 + (0.060 * cooldownNumber.Value), 0)
	cooldownNumber.Value += 1
	cooldownUI.MoveName.Text = name
	cooldownUI.Visible = true
	local ts = game:GetService('TweenService')
	ts:Create(cooldownUI.BarBackground.Bar,, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {Size =,0,1,0)}):Play()
		for _, v in pairs(gui:GetChildren()) do
			if v:IsA("Frame") and child:IsA("Frame") and v.Name == "CooldownUI" and not died then
				if v.Position ~=, 0, 0.025,0) and child.Position.Y.Scale < v.Position.Y.Scale then
					ts:Create(v,, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Position = v.Position -,0,0.060,0)}):Play()		
	if player.Character:FindFirstChild("Humanoid") then
			died = true
			cooldownNumber.Value = 0
	task.delay(cooldown, function()
		if not died then
			cooldownNumber.Value -= 1


I recently figured out why this happens, but can’t figure out how to fix it. When a gui is removed when the other guis are tweening up due to another gui that got removed beforehand, it cancels that tween in the middle of it, then makes the y.scale go up 0.060 in the middle of the tween completely making it go off axis. I’ve tried creating a number value that tracks the fixed yscale value that doesnt change when it’s tweening, then subtract 0.060 from that, but for some reason the guis just fling up sometimes, making it infinitely worse than normal.

You should avoid very specific positions/sizes like this. I’m assuming you positioned the UI with roblox ui tools, which to me is not reliable. I always use the properties window to change anything.

1 Like

Looks like you want a coroutine to tween these:

	local tween = ts:Create(v,, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Position = v.Position -,0,0.06,0)})

Also as @bluebxrrybot stated above, use pixels (the Offset property) and the Properties window in situations like these.

I did not say this, unless you mean a combination of scale and pixels such as,-10,0,10).

My bad, I wasn’t paying attention while writing. But yes, use scale, and if it doesn’t fit, use it in combination with pixels.

Thanks! I tried it and it made the system much more stable and it stopped bugging! I also did what @bluebxrrybot said and made the positions much less specific.

1 Like

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