Since this is a new topic I decided to create a new thread on this, and trust me I tried 3 alternative methods to see if this would change anything such as;
for loop getting each player, and whitelisting the children of the character, (same result)
setting whitelist[character:GetChildren] = true, (same result)
looping through each bodypart when the player’s character is added, adding it to whitelist. (same result)
Now that I’ve tested this with all I know that would work this is actually boggling how I still can’t seem to get this script to work. I added 50 - 1000 part limit to test if that was the problem, same result.
Anyways here’s the script maybe someone else knows the issue of why this isn’t working.
local whitelist = {}
local regions = {}
local model = workspace:WaitForChild("Regions")
for _,part in pairs(model:GetChildren()) do
local areaName = part.Name
local point1X, point1Y, point1Z = part:FindFirstChild("Point1").Position.X, part:FindFirstChild("Point1").Position.Y, part:FindFirstChild("Point1").Position.Z
local point2X, point2Y, point2Z = part:FindFirstChild("Point2").Position.X, part:FindFirstChild("Point2").Position.Y, part:FindFirstChild("Point2").Position.Z
local reg = Region3.new(Vector3.new(point1X, point1Y, point1Z), Vector3.new(point2X, point2Y, point2Z))
regions[areaName] = {region = reg}
local part = Instance.new("Part", workspace)
part.Transparency = .5
part.BrickColor = BrickColor.new("Really red")
part.Anchored = true
part.CanCollide = false
part.CFrame = reg.CFrame
part.Size = Vector3.new(reg.Size.X, reg.Size.Y, reg.Size.Z)
end
while wait(1) do
for name,test in pairs(regions) do
local region = test.region
local parts = workspace:FindPartsInRegion3WithWhiteList(region, whitelist, 1000)
for _,v in pairs(parts) do
print(v)
end
end
end
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
if Character.Parent == nil then Character.AncestryChanged:Wait() end
whitelist[Character]=true
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.Died:Connect(function()
if Character then
whitelist[Character]=nil
end
end)
end)
end)