This script gets the players in a region3 and puts in a table, and both "player in region" and "not in region" are printing, wich shouldn't be happening. This is the script:

local Part = game.Workspace.RaceLocation
local region3 = Region3.new(Part.Position-(Part.Size/2),Part.Position+(Part.Size/2))
local ignore = {game.Workspace.Baseplate,
	game.Workspace.RaceLocation
}

local participants = require(script.Parent.Participants)
local playersInRaceLocation = require(script.Parent.PlayersInRaceLocation)
local debounce = false
game.Players.PlayerAdded:Connect(function(player)
	local function getPlayers()
		local playersInRegion = game.Workspace:FindPartsInRegion3(region3,nil,math.huge)
		for i,v in pairs(playersInRegion) do
			if v.Parent.Name == player.Name and not table.find(participants,player) and not debounce then
				debounce = true
				print(v.Parent.Name)
				print("player in region")				
				table.insert(participants,1,player)
			end
		end
		for i,v in pairs(participants) do
			if not table.find(playersInRegion,v) and not debounce then
				debounce = true
				print("not in region")
				table.remove(participants,1)
			end
		end
		debounce = false
	end
	
	while wait(0.5) do
		getPlayers()
	end
end)

1 comment

0

The code looks ok. But maybe something is happening with debounce. Try puting a print for all the values before the "ifs" to see how are they passing the checks, maybe you find something