Player Leaves Region3 help

Why aren’t my debounces resetting when player leaves region3 area


for _,area in pairs(game.Workspace.Area:GetChildren()) do
	if area:IsA("Part") then
		local region = - (area.Size/2), area.Position + (area.Size))
		local whitelistedParts = Character:GetDescendants()
		local parts = game.Workspace:FindPartsInRegion3WithWhiteList(region, Character:GetDescendants(), #whitelistedParts)
		for _,part in pairs(parts) do
			if part:FindFirstAncestor(Player.Name) then
				Region3Debounce = true
				BeenInRegion3 = true
				AttachedCamera = false
				print("PLAYER LEFT")
				Region3Debounce = false
				AttachedCamera = false


There are a couple of things I want to clarify so I can understand better - first, what is your output (is it printing ‘PLAYER LEFT’ at least, because you only mentioned the debounces not being reset)? Second, are the debounces being set to true in the first place when the player enters (and how do you know this, the script doesn’t have an output for that to tell you if they are in)?

Also two minor things I noticed, is there a reason you are using wait() inside RenderStepped? If it is for trying to slow down the execution, it will still run at the same rate but only delayed on the first frame. The other thing is that you use Area.Size/2 to define your region3 but you only divided by 2 for the first parameter. Not sure if it was intentional or not, just pointing it out in case you are walking out of the area and your script is defining the area bigger than your Area part. This could also cause your debounces to not change when you expect them to.

its not printing player left. i also tried making a if statement debounce to prevent it from running multiple times, and tried making it reset when player left the region, no luck., oh yeah it wasn’t intentional, looks like i forgot to /2 on the other parameter.