Me and my devs made a script so where you clicked on the part it would teleport it somewhere on the baseplate. I added little decorations on the rock and it tp’s the rock but not the decorations on the rock. Why?
script 1:
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
script 2:
rocks = workspace.Rocks:GetChildren()
touching = false
touchingparts = {}
for i=1, #rocks, 1 do
repeat
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