So this is sorta a dupe post but I am gonna explain this better.
When you click on the rock, it will tp the rock to anywhere on the baseplate. I decided to make some decor on the rock but for some reason it only tp’s the rock, not the decor.
This is the script:
rocks = workspace.Rocks:GetChildren()
touching = false
touchingparts = {}
for i=1, #rocks, 1 do
rocks[i].Primary.ClickDetector.MouseClick:Connect(function()
repeat
touching = false
rocks[i].Primary.CFrame = CFrame.new(workspace.RockSpawnArea.Position.X + math.random(-workspace.RockSpawnArea.Size.X/2, workspace.RockSpawnArea.Size.X/2), rocks[i].Primary.Position.Y, workspace.RockSpawnArea.Position.X + math.random(-workspace.RockSpawnArea.Size.X/2, workspace.RockSpawnArea.Size.X/2))
touchingparts = rocks[i].Primary:GetTouchingParts()
for c=1, #touchingparts, 1 do
if touchingparts[c].Name == "terrain" then
touching = true
break
end
end
until touching == false
end)
end
an image to help:
As you can see, it tp’ed the rock and just left the ores behind.
Some info: They are all in a model.
Technically, all that is going on is: When you click the rock, it is supposed to teleport the whole model (5 parts) but only teleports the primary part.