Current code:

local touch = Touch
local debounce = false
touch = touch.Touched:Connect(function(hit)
	if not debounce then
		debounce = true
		print(hit.Parent.Name)
		touch:Disconnect()
		wait()
		debounce = false
	end
end)

I'm trying to make it so it detects the player once, and if the player walks off and gets back on it detects them again but I'm having trouble where it only works once and even if you reset it would detect the player again.

Sorry if this is already a thread.

2 comments

0

The only reason why it works once is because you put touched:Disconnect(). Remove that.

0

Why did you put touch:Disconnect() ?? That breaks the function and doesn't reach the debounce = false line.