GUI not working second time unless reset

Hello. I’ve recently created a GUI in which somebody put’s a question in, and they click submit then it goes for voting for 30 seconds. After that the results are in and it’s meant to be however somebody can do another question, however whenever I try to click the submit button again it doesn’t work at all, I have to reset for it to work.

Any clue or idea as to why? I’d be very thankful.

It would be useful to have some code to look at.

I’m sure it isn’t the code as it says nothing regarding that.

I disagree. Looking at the code could be useful because based on the context you’ve given us we can’t do anything to help.

2 Likes

There doesn’t have to be an error for it to be causing unexpected behaviour. I can’t really help you based on the information you have given. Even your question isn’t that clear verbally speaking.

2 Likes
script.Parent.Submit.RoundedButton.TextButton.MouseButton1Click:connect(function()
	if voteactive.Value == false then
		if script.Parent.Input.TextBox.Text == "QUESTION HERE" or script.Parent.Input.TextBox.Text == "INPUT A QUESTION BEFORE STARTING" then
			script.Parent.Input.TextBox.Text = "INPUT A QUESTION BEFORE STARTING"
			script.Parent.Input.TextBox.PlaceholderColor3 = Color3.fromRGB(255, 3, 3)
			wait(2)
			script.Parent.Input.TextBox.PlaceholderColor3 = Color3.fromRGB(255, 255, 255)
			script.Parent.Input.TextBox.Text = "QUESTION HERE"
		else
			if deb then return end
			deb = true
			local text = script.Parent.Input.TextBox.Text
			VoteStart:FireServer(text)
			local plr = game.Players.LocalPlayer
			script.Parent:TweenPosition(UDim2.new(0, 0, 1, 0), "Out", "Sine", 1.5)
		end
	end
end)

Did you set the deb back to false?

1 Like

One thing: try to reduce the number of repeated references to script.Parent.Input.TextBox by storing it as a local variable instead and referring to that.

The reason why you aren’t able to click it again is because you never set the debounce variable back to false. Because it remains true, the GUI is unsubmittable, which is why resetting your character will restart the script, and the debounce is back to false again, enabling the ability to submit.

    else
		if deb then return end
		deb = true
		local text = script.Parent.Input.TextBox.Text
		VoteStart:FireServer(text)
		local plr = game.Players.LocalPlayer
		script.Parent:TweenPosition(UDim2.new(0, 0, 1, 0), "Out", "Sine", 1.5)
        deb = false
	end
1 Like

Ah thank you, I completely missed that.

1 Like

I gotchu! Make sure to accept the answer so other viewers can easily find the answer if they are having the same problems as you are :slight_smile: