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

How do i continuously check if a part is touching another?

I am attempting to make a drowning system for my game, but whenever a player touches another part, it just stops activating, how do I keep checking if a part is touching another (like every 5 seconds)

2 answers

✓ Accepted answer

You could try this

local debounce = false

script.Parent.Touched:connect(function(hit)
	print("hit")
	local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
	if player then
		if debounce == true then return end
		debounce = true
		local check = player.Character:FindFirstChild("name here")
		if not check then
			--Enable the drowning here
			local newValue= Instance.new("BoolValue")
			newValue.Name = "name here"
			newValue.Parent = player.Character
			script.Parent.TouchEnded:wait()
			--Disable it here	
			newValue()
		end
		debounce = false
	end
end)

1 comment

0

"local check = player.Character:FindFirstChild("name here")"

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