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

How to i get this Region3 script to work properly?

Asked by 4 years ago
Edited 4 years ago

This script is supposed to detect if a part is not inside of a Region3 and bring it back in if it leaves. The script can detect if the part is inside but can not detect if it isn't inside. What do i change in order for it to detect that too?

It is in a normal script and it is located inside of a tool. When equipped, "Preview" is a part that is made inside of the tool and can be moved around.

local regionPart = game.Workspace.RegionPart
local pos1 = (regionPart.Position - regionPart.Size/2)
local pos2 = (regionPart.Position + regionPart.Size/2)
local region = Region3.new(pos1, pos2)
local Preview = script.Parent:WaitForChild("Preview")


while true do
    wait(1)
    local partsInRegion = workspace:FindPartsInRegion3WithWhiteList(region,{Preview},100)
    for i, part in pairs (partsInRegion) do
        if part ~= nil then
            print("Blueprint is in region")
        else
            print("Blueprint is not in region")
            Preview.Position = game.Workspace.DefaultCenter.Position
        end
    end
end

Video of tool: https://www.youtube.com/watch?v=3jmtvgtuU84

0
whats the problem? marine5575 359 — 4y
0
You're missing the WhiteList. Ziffixture 6913 — 4y
0
The missing whitelist gets it to detect if it is there so that's 1 problem fixed. joefrog123 8 — 4y
0
Do you mind checking it 1 more time Feahren? joefrog123 8 — 4y

Answer this question