Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Single button open and close tweened GUI frame?

--(Here is what I tried coding with I want the project to tween from the bottom of the screen upward and back down separately when clicked multiple times. But only with one button to control this. I am not great at coding so I have tried searching on Youtube and also through peoples creations have yet to get this to work with a single button. Can someone help give me the solution to this? If not it is alright I can just use a two button method I guess.)

function pressed()
local ShopFrame = script.Parent.Parent.ShopFrame
	local toggle = false
	
	if not toggle then
		
		toggle = true
		ShopFrame:TweenPosition(UDim2.new(0, 75,1, 10), 'Out', 1)
		ShopFrame.Visible = false
		
	else
		
toggle = false
		ShopFrame:TweenPosition(UDim2.new(0, 75,0.2, 10), 'Out', 1)
		ShopFrame.Visible = true
	end
	end
script.Parent.MouseButton1Down:connect(pressed)

1 answer

✓ Accepted answer

Try this it should work

local Shop = game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel
local states = {0,1}
local selected = 0
script.Parent.MouseButton1Click:Connect(function()
	selected += 1
	local chosenState = (selected%2)
	print(chosenState)
	if states[chosenState] == 0 then
		Shop:TweenPosition(
			UDim2.new(0.322, 0,0.207, 0),
			Enum.EasingDirection.Out,
			Enum.EasingStyle.Linear,
			1,
			false	
		)
	else
		Shop:TweenPosition(
			UDim2.new(0.326, 0,0.4, 0),
			Enum.EasingDirection.Out,
			Enum.EasingStyle.Linear,
			1,
			false	
		)
	end	
end)

			 

3 comments

0

Thank you so much this worked almost entirely.Changed local Shop to = script.Parent.Parent.ScrollableFrame, local selected = 1, and input the correct positions.

0

Also added the Tween at the beginning of the script to close it instantly.

0

No problem glad to help

This discussion is preserved as it was. New answers, comments, and votes are closed.