Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to stop a part from positioning into another part?

So i have this random tree generation code

for i = 1,10 do
local tree = game.ServerStorage.tree
local bottomright = Vector3.new(180,0,-180)
local topleft = Vector3.new(-180,0,180)
local random = Random.new()
local tree = tree:Clone()
tree.Parent = workspace
tree:MoveTo(Vector3.new(random:NextNumber(topleft.X,bottomright.X),2.5,random:NextNumber(topleft.Z,bottomright.Z)))
end

It work's but the thing is the trees clip into each other i've attempted to fix this by using moveto which automatically moves away if its clipping into a part but it only moves away upward so it just makes the script more buggy ;'/ Anyway is there any way i can stop the trees from clipping / positioning into each other?

1 answer

✓ Accepted answer
tree.Touched:Connect(function(hit)
if hit == othertree then
-- move the tree further away, you can do this
end
end)

1 comment

0

Wont work because what if there is another tree in my moving trees location when i move further away

This discussion is preserved as it was. New answers, comments, and votes are closed.