Tween Not Working?

I am working on a menu that when it transitions from different screens, the buttons tween off screen, change the text, and then tween back on screen. The only problem is that the buttons don’t come back and I have no clue to why. If anyone knows what my problem is, can you show me how to fix it? Thanks!

Here is my code:

function fade(out) -- out: If to tween off screen = true, to tween on screen = false
	local mainbuttontweendelay = 0.3 -- Duration of the tween
	local pos = { -- Just the tween info. I thought this was the problem, but I don't believe so...
		botmainbuttonsout = UDim2.new(-1, 0, 0.6, 0),
		botmainbuttonsin = UDim2.new(0, 0, 0.6, 0),
		mainbuttontweenstyle = Enum.EasingDirection.In, Enum.EasingStyle.Sine, mainbuttontweendelay
	}
	if out == true then -- Tween off screen
		bot:TweenPosition(pos.botmainbuttonsout, pos.mainbuttontweenstyle) -- Tween Bottom Button off screen(Works)
		wait(mainbuttontweendelay)
	elseif out == false then -- Tween in to screen
		bot:TweenPosition(pos.botmainbuttonsin, pos.mainbuttontweenstyle) -- Tween Bottom Button on screen(Does not work), I put prints before and after this line and both fired, but it still did not tween
		wait(mainbuttontweendelay)
	end
end

function topclicked()
	if running == false then -- So multiple functions don't get fired at once
		running = true

		fade(true) -- Bottom button should tween off screen(Works)
		bot.DisplayLabel.Text = "Back" -- Change text of bottom button(Works)
		fade(false) -- Bottom button should tween back on screen(Does not work)

		wait(rundelay)
		running = false
	end
end

NOTE: I edited my code above to shorten it.

1 Like

Now, I doubt this will work, but try enabling the override option.

In other words, make pos:

	local pos = {
		botmainbuttonsout = UDim2.new(-1, 0, 0.6, 0),
		botmainbuttonsin = UDim2.new(0, 0, 0.6, 0),
		mainbuttontweenstyle = Enum.EasingDirection.In, 
        Enum.EasingStyle.Sine, -- keep formatting the same! don't just have several values on one line when you've been adding line breaks before.
        mainbuttontweendelay, 
        true, -- the override option
        function(state) -- this function gets called when the tween finishes, use it to help debug
                print(state.Value) -- prints whether the tween happened or not, check https://developer.roblox.com/en-us/api-reference/enum/TweenStatus for more info
        end
	}

I apologize for my formatting, but I tried your code and it still does not work. It also did not print…

Also, I just went to Roblox’s website on :TweenPosition() and applied their line of code to mine, which looks like:

local willPlay = bot:TweenPosition(pos.botmainbuttonsin, pos.mainbuttontweenstyle)
if willPlay then
      print("The tween will play")
else
      print("The tween will not play")
end
wait(mainbuttontweendelay)

And it printed “The tween will not play”…