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.
how do i delete a cloned and teleported part if the space is occupied?
1 answer
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).
2 comments
how do i put the region3 into the second script? it gives me the error "Unable to cast Function to Region3"
and what do you mean mission of cosmic proportions?, im only a beginner in scripting
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
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
create a variable, local reg3 = Insert the functon here, and then put that inside of the other part