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

Why is my debounce in my script messing up other scripts?

Explanation: Okay guys so I have two buttons inside of a Model and also an IntValue inside the Model that acts like a debounce for the progress. Whenever the button is pressed it sets the IntValue to 1 so that no other button can be pressed until the previous button pressed finishes everything it has to do.

Issue: For some reason if I press one button and let it run through, when I try to go press the second button nothing happens, even though the IntValue is set to 0. I have a feeling it is due to the "enabled = true" but even if they are separate scripts it should not interfere? Do I need to change the name enabled = true to something like enabled1 = true, enabled2 = true, etc for each script?

Button 1

open = true
self = script.Parent
enabled = true
inProgress = script.Parent.Parent.Value

function Click()
if enabled == true then
	enabled = false		
	if inProgress.Value == 0 then
		print("inprogress is 0")
		inProgress.Value = 1	
		print("enabled == true now setting to false")
		self.BrickColor = BrickColor.new("Bright red")
		game.Workspace.Song:Play()
		wait(36)
		inProgress.Value = 0
		wait(10) --Wait 10 seconds before being able to press again
		self.BrickColor = BrickColor.new("Bright green")
		enabled = true
		end
	end
end

script.Parent.ClickDetector.MouseClick:connect(Click)

Button 2

open = true
self = script.Parent
enabled = true
inProgress = script.Parent.Parent.Value

function Click()
if enabled == true then
enabled = false
	if inProgress.Value == 0 then
		print("inprogress is 0")
		inProgress.Value = 1		
		print("enabled == true now setting to false")
		self.BrickColor = BrickColor.new("Bright red")
		game.Workspace.Landing:Play()
		wait(24)
		inProgress.Value = 0
		wait(10) Wait 10 seconds before being able to press again
		self.BrickColor = BrickColor.new("Bright green")
	enabled = true
	end
end
end

script.Parent.ClickDetector.MouseClick:connect(Click)

1 comment

1

Script 2, line 17, you forgot to add --before the note, maybe that is messing up your second script. Just try pressing the second first and see if it works.

1 answer

First of all, try using a BoolValue instead of an IntValue, since you're basically using a boolean flag. (Not a solution to your issue, just a general tip)

Second, check the output window. Odds are you're getting a syntax error on line 17 of the second script, since you forgot to comment out your comment.

1 comment

0

Okay I will use bool values instead I guess. The output doesn't give me anything at all, I can't figure out what it is.

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