so i made a region detecting script with region3 but its not working properly
here is an image
as you can see i am not in both mainland region or swamp region but the region3 still detects them (the region 3 is in humanoid root part position and has humanoid root part size)
here is the script:
local rs = game:GetService("RunService")
rs.Heartbeat:Connect(function()
local torso = script.Parent:WaitForChild("HumanoidRootPart")
local region = Region3.new(torso.Position - Vector3.new(torso.Size.X/2,torso.Size.Y/2,torso.Size.Z/2),torso.Position + Vector3.new(torso.Size.X/2,torso.Size.Y/2,torso.Size.Z/2))
local parts = workspace:FindPartsInRegion3WithWhiteList(region,workspace.Regiony2:GetChildren())
local highest
local chosenregion
for i,v in pairs(parts) do
print(v)
if v:FindFirstChild("Priority") ~= nil then
if highest == nil then
highest = v.Priority.Value
chosenregion = v
elseif v.Priority.Value > highest then
highest = v.Priority.Value
chosenregion = v
end
end
end
if chosenregion ~= nil then
if game.ReplicatedStorage.Remotes:FindFirstChild(chosenregion.Name) ~= nil then
local remote = game.ReplicatedStorage.Remotes:FindFirstChild(chosenregion.Name)
remote:FireClient(game.Players:GetPlayerFromCharacter(torso.Parent))
end
end
wait()
end)