How do i make frame tween toggable

script:


local plrgui = plr.PlayerGui

local screengui = plrgui.ScreenGui2

local credits2 =screengui.Frame

local credit = screengui.TextButton

local ts = game:GetService("TweenService")

local Info = TweenInfo.new(1)

local Tween4 = game:GetService("TweenService"):Create(credits2,Info,{Position = UDim2.new(-0.009, 0,0, 0)})

local Tween5 = game:GetService("TweenService"):Create(credits2,Info,{Position = UDim2.new(-0.900, 0,0, 0)})

credit.MouseButton1Click:Connect(function()

if credits2.Position == UDim2.new(-0.900, 0,0, 0) then

Tween4:Play()

else

Tween5:Play()

print("tweened")

end

end)

Use a state variable/flag which represents the state of the frame.

Here’s some pseudo-code to guide you in the right direction.

local toggle = false

button.MouseButton1Click:Connect(function()
	toggle = not toggle
	if toggle then
		--Play first tween.
	else
		--Play second tween.
	end
end)
1 Like