Player Detection not exactly working

So basically trying to get something that just finds players in “Out of bounds areas” (Parts) and heres what i got

local function OutOfBoundsCheck()	
	while task.wait() do
		local T = {}
		local T_ = {}		
		
		if #OutOfBounds:GetChildren() > 0 then
			for i, v in ipairs(OutOfBounds:GetChildren()) do
				if v:IsA("BasePart") then
					local StuffInside = workspace:GetPartsInPart(v, OverlapParams.new())

					for i, v in ipairs(StuffInside) do	
						table.insert(T, v)	
					end			
				end
			end

			if #T > 0 then
				for i, v in ipairs(T) do
					if v.Parent:FindFirstChild("Humanoid") and not table.find(T_, v.Parent) then
						table.insert(T_, v.Parent)
						
						local Coroutine = coroutine.create(OutOfBoundsThing)
						coroutine.resume(Coroutine, v.Parent, true)
						
					elseif not table.find(T_, v) then
						table.insert(T_, v)
						local Coroutine = coroutine.create(OutOfBoundsThing)
						coroutine.resume(Coroutine, v, false)
					end
				end
			end
		end
		
		T = {}
		T_ = {}
	end
end

but even with the player if statement, it still sends the normal characters limbs most times (like left leg, right leg, HRP, ect)

Also ive tried changing the elseif to something a little better

elseif not table.find(T_, v) or not table.find(T_, v.Parent) then

but it still fires with limbs most times
Not sure why its not working as intended

1 Like

To detect players from BaseParts, you can do something like this:

local PS = game:GetService("Players")

local part = --insert part

for _,v in ipairs(workspace:GetPartsInPart(part)) do
	local char = v:FindFirstAncestorWhichIsA("Model")
	local player = PS:GetPlayerFromCharacter(char)

	if player then
		warn("FOUND CHAR: " .. char.Name)
	end
end
2 Likes

This did infact fix it
Thanks :smiley: :+1: