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

How to move a model via CFrame ?

Title is the Question .

mouse.Button1Down:Connect(function()
	local target = mouse.Target
	if target ~= nil and target.Name == "MapGrid" then
		local clone = examplebuildingt:Clone()
		clone:GetBoundingBox().CFrame = target.CFrame + Vector3.new(0,clone:GetBoundingBox().Y / 2 , 0)
		clone.Parent = game.Workspace
	end
end)

1 answer

✓ Accepted answer

"GetBoundingBox" returns CFrame, so you don't need to index it with [.CFrame], also it returns a copy of the model's bounding box so changing it won't change the model.

If you want to move a model, you need to set its [.PrimaryPart], usually it's the main part of the model and then call "SetPrimaryPartCFrame":

clone:SetPrimaryPartCFrame(target.CFrame + Vector3.new(0, clone:GetBoundingBox().Y / 2, 0))

"SetPrimaryPartCFrame" will move all other parts of the model automatically.

3 comments

0

didnt work

0

Did you SET the PrimaryPart first?

0

Ok it works now

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