UI TweenPosition working one way

Hello I am trying to make an animation on a moving UI, when we click on the playBTN button if the frame is visible we have the animation that shows a frame coming from the right and if the frame is already visible I want the opposite, except that only works when the frame is not visible, why?

playBTN.MouseButton1Click:Connect(function()
	--ui.Enabled = false
	--rs.Events.UI.MainMenu.Deploy:FireServer()
	--currCamera.CameraType = Enum.CameraType.Custom
	--workspace.Camera.CameraSubject = plr.Character:FindFirstChildOfClass("Humanoid")
	local frame = script.Parent.PlayFrame
	
	if not db_play then
		if frame.Visible then 
			frame.Position = frame.Parent.PlayFrame_End.Position
			frame:TweenPosition(
				frame.Parent.PlayFrame_Start.Position, -- Start Position
				"Out",
				"Quad",
				.5,
				false
			)
			frame.Visible = false
			db_play = true
			wait(0.5)
			db_play = false
		else 
			frame.Position = frame.Parent.PlayFrame_Start.Position
			frame.Visible = true
			frame:TweenPosition(
				frame.Parent.PlayFrame_End.Position, -- End Position
				"Out",
				"Quad",
				.5,
				false
			)
			db_play = true
			wait(0.5)
			db_play = false
		end
	end
end)

image

1 Like

TweenPosition doesn’t yield, when you tween the frame to Start Position you immediately changed the frame’s visible to false

1 Like

No ? I am waiting the end of the animation.

Ah alright I understand, thank you. I had to move the frame.Visible = false after wait(5).

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