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

how do i delete a cloned and teleported part if the space is occupied?

Asked by 6 years ago
Edited 6 years ago

i want to teleport a part to somwhere where and delete it iif there is already that part there. and i dont want to delete the part that is already there and replace it with the one i'm cloning.

0
use a touched event to see if the part is touching an existing one in the location. don't place a new part if it is touching Legoman654 100 — 6y
0
create a variable, local reg3 = Insert the functon here, and then put that inside of the other part theCJarmy7 1293 — 6y

1 answer

Log in to vote
0
Answered by
theCJarmy7 1293 Moderation Voter
6 years ago
Edited 6 years ago

To accomplish this mission of cosmic proportions, you could use a Region3 and :FindPartsInRegion3()

To use Region3.new() you would need 2 vector3 positions, one for each corner of the region 3.

To make a region3 without bothering with the corners of the part, you could use this function (taken straight from the wiki) to bother with the corners of the part for you.

local function CreateRegion3FromLocAndSize(Position, Size)
    local SizeOffset = Size/2
    local Point1 = Position - SizeOffset
    local Point2 = Position + SizeOffset
    return Region3.new(Point1, Point2)
end

Simply put in the position and size you want, and then run something like this:

game.Workspace:FindPartsInRegion3(PutTheRegion3Here)

The above will return a table of the parts inside the region3, using this information you could do whatever it is you were trying to do (I couldn't understand all that well with all the spelling and grammar mistakes).

0
how do i put the region3 into the second script? it gives me the error "Unable to cast Function to Region3" SLENDERMANCLONE -27 — 6y
0
and what do you mean mission of cosmic proportions?, im only a beginner in scripting SLENDERMANCLONE -27 — 6y
Ad

Answer this question