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

How to set model rotation?

Heyo, I wan't to set a model rotation, this works kinda works but it adds on to the rotation. So how would I set it and not just add on to the rotation amount?

I'm sorry if I'm not making sense I just don't know how to explain it.... Basically I want the rotation = what I set and not the original rotation+what I set

function rotatemodel(model,center,rotation)
	for i,v in ipairs(model:GetChildren()) do
		if v:IsA("BasePart") then
		v.CFrame=((CFrame.new(center)*rotation)*CFrame.new((v.Position-center)))*(v.CFrame-v.Position)
		--elseif v:IsA("Model")or v:IsA("Folder") then
		--rotatemodel(model,center,rotation)
		end	
	end
end
local tabel = game.Workspace["Red Couch"]
rotatemodel(tabel,tabel.Base.Position,CFrame.Angles(math.rad(-0), math.rad(22.5), math.rad(0)))

2 answers

✓ Accepted answer

You can put an invisible part in the very middle of your model, and set the PrimaryPart to that part. After you can just modify that part with :setPrimaryPartCFrame and it will mess with the whole model. Basically you can rotate, and position the whole model through that one part. :)

Hope this helped!

Sincerely, jmanrock123

2 comments

0

game.Workspace["Red Couch"]:setPrimaryPartCFrame(game.Workspace["Red Couch"].Base.CFrame*CFrame.Angles(math.rad(-0), math.rad(22.5), math.rad(0)))

0

That does the same thing, how would I fix that?

`local x, y, z = game.Workspace["Red Couch"].Base.CFrame:toEulerAnglesXYZ() game.Workspace["Red Couch"]:setPrimaryPartCFrame(game.Workspace["Red Couch"].Base.CFrameCFrame.Angles(x-1, y*-1, z*-1)*CFrame.Angles(math.rad(-0), math.rad(22.5), math.rad(0)))

`

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