Why wont this button work?

Hey so when you first click the button the gui comes how its suspose to but when you click it again it doesnt go back and i have no idea why here is my code:

Local script (Also part of a bigger script)

creditsButton.MouseButton1Click:Connect(function()
	local debounce1 = false
	if debounce1 == false then
		debounce1 = true
		logo.Rotation = 0
		logo:TweenSizeAndPosition(UDim2.new(2.132, 0,0.81, 0),UDim2.new(0.904, 0, 0.078, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,1)
		wait(1)
		logoTween1:Play()
		wait(2.1)
		logo:TweenSizeAndPosition(UDim2.new(0.807, 0,0.272, 0),UDim2.new(0.096, 0, 0.022, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,1)
		wait(1.1)
		script.Parent.CreditsFrame:TweenPosition(UDim2.new(0.346, 0, 0.187, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,2)
		wait(1.5)
		script.Parent.CreditsFrame.Frame:TweenPosition(UDim2.new(0.053, 0, 0.053, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,2)
	else
		wait(0.1)
		debounce1 = false
		script.Parent.CreditsFrame:TweenPosition(UDim2.new(2, 0, 0.187, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,2)
		wait(1.5)
		script.Parent.CreditsFrame.Frame:TweenPosition(UDim2.new(2, 0, 0.053, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,2)
	end
end)

put this outside the function, not inside

3 Likes

Isolate denounce1 and also make a path for creditsbutton, no need if there is but just unincluded. Also for logo too.

1 Like

What do you mean by Make a path?

Example:

local creditsbutton = script.Parent.Parent
1 Like

There is one. (30aaaaaaaaaaaa)

You need to put this

wait(0.1)
debounce = false

right before the else
I hope that fixes it.

I cant see it for the logos and the credits button, it’s ok if there is one already.
It says part of a bigger script, so I assume its there.

1 Like

There is one this is just a piece of the script.

Yep, thought so lol, I was just wondering

1 Like