So I have a procedural town system, and I use MoveTo() to randomly place houses where they could be to form a town. Sometimes, however, terrain will get in the way, making the anchored house float in the air above the ground. So is there a way I can use the MoveTo() function to CFrame the house into the ground? or could I get the children of all the parts in the model and do something with them? All answers appreciated, Thank You. ~Xduel
✓ ANSWER ACCEPTED
How can I use MoveTo() on a model and have it CFrame into parts?
1 answer
✓ Accepted answer
Instead of using the MoveTo method, use the TranslateBy method. It doesn't check for collisions.
local model = Workspace.Model --The model you're moving
local point = Vector3.new(100,0,100) --Where you want to move it to
model:TranslateBy(point-model:GetModelCFrame().p)
--Subtracting the two points gives us what we need to offset the model by.
In your case, this might make the house teleport into the ground. However, we can easily fix that by translating it up by half its height.
local model = Workspace.Model
local point = Vector3.new(100,0,100)
model:TranslateBy(point-model:GetModelCFrame().p + Vector3.new(0,model:GetModelSize().Y/2,0))
Note that because it does not check for collisions, you need the exact point on the ground, otherwise the model could be floating or sinking.
1 comment
0
Thanks for the help, I also until now didn't know about GetModelCFrame or GetModelSize!
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Just make the terrain flat... Or I suppose you could use a for loop and change the CFrame of each individual part.
Well that wasn't very helpful. Thanks for the consideration I guess.