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

How do i set the rotation of a model?

i am making a game with a model which has to be rotated a certain direction depending on a certain value, but the problem is all scripts that I found add rotation to the frame, here is my script for you to understand more

if Direction == "East" then
		Parent:SetPrimaryPartCFrame(Parent.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(90), 0))
end

in summary, I need to set the rotation to 0,90,0, not add 0,90,0

2 answers

✓ Accepted answer

Instead of just adding the 90 degrees as you are in that code you can simply create a new CFrame that uses that position and then add the degrees to that new angle

example:

Parent:SetPrimaryPartCFrame(CFrame.new(Parent.PrimaryPart.CFrame.Position) * CFrame.Angles(0, math.rad(90), 0))

Multiplying CFrames is usually used to offset a part relative to another part. In your case you want to directly change the orientation.

if Direction == "East" then
	Parent.PrimaryPart.Orientation = Vector3.new(0, 90, 0)
end

4 comments

0

this only rotates the primary part, i want to rotate the entire model with the primary part as the centre of mass

0

Unanchor all the parts in the model and then weld them all to the primary part.

0

that didnt work

0

I would give prooheckcp's solution a try.

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