[SOLVED] None of the 3 debounces work

Alright I literally have 3 debounces and I change the parent of the part that activates the script to workspace but the script still repeats itself. I have no idea whats going wrong, I placed debounces before every function but nothing works… Please help me

Here is the main part of the code that is being used (note I have a modulescript in which most of the functions are located)

elseif v.Name == "SinglePossibility" and detectorDebounce == "False" then
		
		v.Touched:Connect(function(hit)
			
			detectorDebounce = "True"
			v.CanTouch = false
			v.CanQuery = false
			MainDetector = v
			local OGvParent = v.Parent
			v.Parent = workspace
			local FigureDetector = v.FigureDetector
			
			local jumpscarePossibilities = {}
			local chosenJumpscare

			for i, n in pairs(v.JumpscarePossibilities:GetChildren()) do
				table.insert(jumpscarePossibilities, n.Name)
			end

			chosenJumpscare = jumpscarePossibilities[math.random(1, #jumpscarePossibilities)]
			print("Chosen "..chosenJumpscare)
			
			if(hit.Parent:FindFirstChild("Humanoid"))then
				if vDebounce == "False" and chosenJumpscare == "shadowAppear" then

					vDebounce = "True"
					local character = hit.Parent
					local humanoid = character.Humanoid
					PlayerPart = character.HumanoidRootPart
					jumpscareData.shadowAppear(PlayerPart, v, FigureDetector, FigureDetector.FigurePos, "North", "North")
					PreviousJumpscare = chosenJumpscare
					v.TimesActivated.Value += 1
					vDebounce = "False"

				elseif vDebounce == "False" and chosenJumpscare == "objectThrown" then

					vDebounce = "True"
					local character = hit.Parent
					local humanoid = character.Humanoid
					PlayerPart = character.HumanoidRootPart
					jumpscareData.objectThrown(PlayerPart, v, FigureDetector, "Beans")
					PreviousJumpscare = chosenJumpscare
					v.TimesActivated.Value += 1
					vDebounce = "False"

				elseif vDebounce == "False" and chosenJumpscare == "shadowSighting" then

					vDebounce = "True"
					local character = hit.Parent
					local humanoid = character.Humanoid
					PlayerPart = character.HumanoidRootPart
					jumpscareData.shadowSighting(PlayerPart, v, FigureDetector.FigurePos, LightGroup, "North")
					PreviousJumpscare = chosenJumpscare
					v.TimesActivated.Value += 1
					vDebounce = "False"
				end
			end
			v.CanTouch = true
			v.CanQuery = true
			v.Parent = OGvParent
			detectorDebounce = "False"
		end)
1 Like

Don’t you need a wait() in between the VDebounce

2 Likes

it seems like he didn’t put task.wait(XSeconds) or wait(XSeconds) etc.

So it turns to False instantly which makes it work but since there are no waits, it doesn’t wait too

2 Likes

fixed it somehow, I used a completely different technique which first inserted all special detectors into a tabel and then I created 2 functions to turn on and off detector canTouch and in the end I used a i, v in pairs(detectortabel) to loop through all the detectors. Thanks for the help guys!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.