GUI animation not running

Hello developers,

I have an issue that I have no idea how to fix basically, it skips one line of a gui tween,
script;

local Home = script.Parent.Main
local Economy = script.Parent.Economy

local Loading = script.Parent.Loading


Home.Classes.Economy.MouseButton1Click:Connect(function()

	Home.Classes.Economy:TweenPosition(UDim2.new(0,0,1.5,0),"In","Back")
	wait(0.5)
	Home.Classes.Business:TweenPosition(UDim2.new(0.367,0,1.5,0),"In","Back")
	wait(0.5)
	Home.Classes.Flex:TweenPosition(UDim2.new(0.735,0,1.5,0),"In","Back")
	wait(1)
	Home.Classes.Economy.Visible = false
	Home.Classes.Business.Visible = false
	Home.Classes.Flex.Visible = false
	Home:TweenPosition(UDim2.new(0,0,-1,0))

	
	Loading:TweenPosition(UDim2.new(0,0,0,0)) -- Brings loading screen to middle
	wait(5)
	Loading:TweenPosition(UDim2.new(0,0,-1,0)) -- Brings loading screen to up
	Economy:TweenPosition(UDim2.new(0,0,0,0)) -- Brings Economy screen to middle
	
	
	wait(0.3)

	print("BriningLoadingDown")

	Home:TweenPosition(UDim2.new(0,0,1,0))
	Loading:TweenPosition(UDim2.new(0,0,1,0)) -- Skips this line.
	wait(2)

end)

EDIT: The Loading screeen needs to go to 0,0,0,0 then 0,0,-1,0 then 0,0,1,0 . It doesnt stay at 0,0,-1,0 as when it appears again, I dont want it to over lap with other screens (Frames)

You didn’t specify how long each tween should run, the default is 1 second

1 Like

Yes, but its only one line that doesnt work, and i’ve never needed to specify how long it takes before.

Which bit of the script doesn’t work

This part here, its meant to bring the frame back down underneath the main frame.

Shouldn’t that be Loading:TweenPosition(UDim2.new(0,0,-1,0))
make it negative

Somehow, negative is bringing it up instead of down.

Its because your using offset "

try printing the value that the :TweenPostion() returns. It returns a bool specifying weather or not the tween will play. Maybe it is just not playing.

How would I be able to do that, sorry?

you can either do

print(GuiObject:TweenPosition(Udim2.new()))

or

local wasTweened = GuiObject:TweenPosition(Udim2.new())
print(wasTweened)

I think what’s probably happening is the gui is getting stuck because another tween starts before an old one is finished.

I recommend not using built in gui tweening, but instead using normal tween service. It’s what I do, and it works great. You wouldn’t have the issue of the gui getting stuck anymore, and it gives you more options for your tweens.

Hope this helps.

Edit: btw I think the part that breaks it is the wait(0.3). The loading tween is trying to go to -1, and then before it can finish you try tweening it to 1.

Thank you, I found that i just needed to increase the wait to 1 instead of 0.3, thanks for the help!

1 Like