Hey.
I recently made a script to detect players, but it refused to work. For some reason, FindPartsInRegion 3 does not detect objects inside the region.
Here all my script:
Server Side
local oop_module = require(game.ReplicatedStorage.Modules.ZonesOOP)
local Table = {}
for i,v in pairs(zones:GetChildren()) do
table.insert(Table,oop_module.new(v))
end
while wait(.5) do
for i,v in pairs(Table) do
v:Check()
end
end
ModuleScript
local zones = {}
zones.__index = zones
function zones.new(part)
local zone = {}
setmetatable(zone,zones)
zone.Part = part
local x = zone.Part.Position + Vector3.new(zone.Part.Size.X/2,zone.Part.Size.Y/2,zone.Part.Size.Z/2)
local z = zone.Part.Position - Vector3.new(zone.Part.Size.X/2,zone.Part.Size.Y/2,zone.Part.Size.Z/2)
zone.Region = Region3.new(x,z)
return zone
end
function zones:Check()
local parts = game.Workspace:FindPartsInRegion3(self.Region,nil,math.huge)
for _,hit in pairs(parts) do
print('cycle',hit.Name)
end
end
return zones