Hello. I want to detect if a player is within a Region3 so I can change the workspace gravity locally. However, I keep getting this error with my FindPartsInRegion3WithWhiteList function.
Script:
local player = game.Players.LocalPlayer
local character = player.Character
local playerFound = false
local earth = workspace.Earth.Atmosphere
local region = Region3.new(
earth.Position - earth.Size/2,
earth.Position + earth.Size/2
)
local whiteList = {}
for i, v in ipairs(character:GetChildren()) do
if v:IsA("BasePart") then
table.insert(whiteList, v.Name)
end
end
while wait(1) do
local partsInRegion = workspace:FindPartsInRegion3WithWhiteList(
region, whiteList, math.huge
)
for i, v in ipairs(partsInRegion) do
if v:FindFirstAncestor(player.Name) then
if workspace.Gravity ~= 196.2 then
playerFound = true
break
end
else
playerFound = false
end
end
if playerFound == true then
workspace.Gravity = 196.2
break
end
end
Error: