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

Cframe changes position instead of rotation?

Asked by 5 years ago
model = script.Parent
model.PrimaryPart = script.Parent.RotationPart
    model:SetPrimaryPartCFrame(CFrame.new(script.Parent.PrimaryPart.Orientation + Vector3.new(0,0,1)))

I am trying to rotate a model but when I run this script the model teliports to a certain spot, the orientation property changes rotation so I don't understand why its moving position instead.

1 answer

Log in to vote
0
Answered by
xPolarium 1388 Moderation Voter
5 years ago
Edited 5 years ago

You are adding a Vector3 and Orientation together to change the position. You are not doing anything to the Rotation of the model at all.

You use CFrame.Angles to change the rotation. This also takes in radians so we use math.rad to convert.

local model = script.Parent

--You can manually do this in the properties window too
model.PrimaryPart = model.RotationPart 

--This will rotate the part 45 degrees on the y-axis
local newRot = CFrame.Angles(0, math.rad(45), 0)

model:SetPrimaryPartCFrame(model.PrimaryPart.CFrame * newRot)

edit: fixed function error

0
it works, thank you. mantorok4866 201 — 5y
Ad

Answer this question