Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

FindPartsInRegion3 doesn't work in my game. Why?

Asked by
Bisoph 5
6 years ago

I'm trying to make a ship-battling game where you fight other people in ships.

Instead of using a manual regeneration for the ships, I decided to make them automatically regenerate once the previous ship leaves its station. For this, I used Region3s

I put the min and max Vector3 values the position of two parts that are located in the top-rear and bottom-front of where the ship initially spawns.

But, for some reason, it says that there are no parts inside that region, even though there obviously are. Why is this?

Here is my regeneration script's source:

local station = script.Parent

local function checkIfShipPresent()
    local region = Region3.new(
        station.RegionStart.Position,
        station.RegionEnd.Position
    )
    local parts = workspace:FindPartsInRegion3(region, nil, math.huge)

    for i = 0, #parts do
        print(parts[i].Name)
    end
end

wait(1)
checkIfShipPresent()
0
wait it says there's an error because im getting the 0th property of a table so i set it to 1 and it prints nothing Bisoph 5 — 6y
0
FindPartsInRegion3 isn't finding anything for me either. Trainsparency 39 — 6y

Answer this question