local credits = false
local SG = script.Parent.Parent.Parent
local debounce = false
script.Parent.MouseButton1Click:connect(function ()
if credits == false and debounce == false then
credits = true
debounce = true
end
if credits == true and debounce == false then
credits = false
debounce = true
end
if credits == true and debounce == true then
SG.Credits.Visible = true
for i = 1, 14 do
SG.Credits.Position = SG.Credits.Position + UDim2.new(0.05,0,0,0)
wait(0)
if i == 14 then
script.Parent.Text = "Close Credits"
debounce = false
end
end
end
if credits == false and debounce == true then
for i = 1, 14 do
SG.Credits.Position = SG.Credits.Position - UDim2.new(0.05,0,0,0)
wait(0)
if i == 14 then
script.Parent.Text = "Credits"
SG.Credits.Visible = false
debounce = false
end
end
end
end)
So, the debounce here is to avoid that people that clicks a milion a times per second to open something and bugs the gui, right? Well im using debounce, but when i click alot of times on the button, the gui bugs. Whats the problem?

2 comments
You're setting credits to true and then asking if credits is true. the end if at line 9 looks like it should be elseif.
Waffle, it is supposed to be like that, credits is the gui. If credits is true, when you click, is false, that will make the gui invisible, and if credits is false and when i click credits is true, the credits gui will be visible, and i already tried to put an elseif