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