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

How to make an tween gui open and close with the same button?

Im trying to open a shop with a button once the shop is open you can close it with that same button. I tried to attempt doing that but it didn't work; here is the script i used: i used this in a local script

local open = script.Parent.Parent.Open
open.Value = true

script.Parent.MouseButton1Click:Connect(function(click)
		script.Parent.Parent:TweenPosition(UDim2.new(-0.111, 0,0.211, 0),true)
		wait()
	script.Parent.Text = ">>"
	open.Value = false
end)

wait()

if open.Value == false then
	script.Parent.MouseButton1Click:Connect(function(click)
		open.Value = true
		script.Parent.Parent:TweenPosition(UDim2.new(0, 0,0.211, 0),true)
		wait()
		script.Parent.Text = "<<"
	end)	
end	

1 comment

0

put lines 13-20 inside the script.Parent.MouseButton1click

1 answer

✓ Accepted answer

Problem: your if statement on line 13 is checked when the player joins then isn't checked at all.

local open = script.Parent.Parent.Open
open.Value = true

script.Parent.MouseButton1Click:Connect(function()
	if open.Value == true then open.Value = false
	        script.Parent.Parent:TweenPosition(UDim2.new(-0.111, 0,0.211, 0),"Out","Quad",1,true)
	     	wait()
		script.Parent.Text = ">>"
	else
		open.Value = true
	        script.Parent.Parent:TweenPosition(UDim2.new(0, 0,0.211, 0),"Out","Quad",1,true)
	        wait()
      		script.Parent.Text = "<<"
	end
end)

Try that

2 comments

0

Just a question, Why should i put the 1, "quad", and "out" in the script what does it do?

0

The parameters "Out" and "Quad" are the way it tweens, its design... There's more like Elastic and Bounce, etc... 1 is the time and true is whether it can be overridden.

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