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

How can i detect when the player leaves this part?

Debounce = false
while task.wait() do
	local Zone = workspace:GetPartsInPart(script.Parent)
	for i, v in pairs(Zone) do
		if v.Name == "UpperTorso" and not Debounce then
			Debounce = true
			print("Player detected")	
			wait(2)
			Debounce = false
			return end
		if Debounce == true then
			print("player left")
			wait(2)
			Debounce = false
		end
	end
end

This works normally as a touch script, but i need it to print properly when the player enters and when the player leaves. Any help is appreciated! Edit: Replaced confusing words with more confusing words

1 answer

Just solved it lol, i thought "Return" just broke the loop and brought it back to the top. fixed it with a proper break

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