Touched:Connect debounce not working multiple times?

Hey, I have a script that starts dialogue whenever you touch a part with dialogue information that’s in this “Touched Actors” folder. My current issue right now is, despite the debounce being in there, the debounce only works like one time. After leaving the area, the script waits five seconds and then disables the debounce, allowing the script to be fired again. Sounds normal. But after this, the debounce will not prevent the script from firing multiple times again. If I leave the area and re-enter, the script will not wait 5 seconds and instead fire immediately.

This is just for touching the same part, though. There are multiple parts with dialogue in this folder. When I try touching the same part multiple times, the debounce functions once and then not again. But if I move to a different part in the folder, the debounce works again like normal, then stops working on that part, and all other parts’s debounces will work again.

for i, v in pairs(game.Workspace["Touched Actors"]:GetChildren()) do
	v.Touched:Connect(function(hit)
		if db == false and hit.Parent:FindFirstChild("Humanoid") then
			db = true
			if v.CanSpeak.Value == true then
				v.CanSpeak.Value = false
				local diainfo = require(v.DialogueInfo)
				local scene = "placeholder" --get the module for day/scene tracker and send to client
				TalkStart:FireAllClients(diainfo, scene, v)
			end

		end
	end)
		game.ReplicatedStorage.TalkEnd.OnServerEvent:Connect(function()
		v.TouchEnded:Connect(function()
			wait(5)
			v.CanSpeak.Value = true
			db = false
		end)
	end)
end
1 Like

Touched only fires when the touch happens.
If you’re running through the i, v loop you have to be firing the touched event within the split second it’s checking that Part inside the folder.