Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How do i set the rotation of a model?

Asked by 2 years ago
Edited 2 years ago

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

Log in to vote
1
Answered by 2 years ago

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))
Ad
Log in to vote
0
Answered by
sifn 70
2 years ago

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
0
this only rotates the primary part, i want to rotate the entire model with the primary part as the centre of mass 123jangamer321 28 — 2y
0
Unanchor all the parts in the model and then weld them all to the primary part. sifn 70 — 2y
0
that didnt work 123jangamer321 28 — 2y
0
I would give prooheckcp's solution a try. sifn 70 — 2y

Answer this question