Rotating a model based off of its primary part

Hello, I have a tool that places a model down based on a player’s location but I was wondering how I would rotate it?

I vaguely remember the use of SetPrimaryPartCframe but can’t fully remember the code.

I currently have:

p:SetPrimaryPartCFrame(p.CFrame * CFrame.Angles(0,180,0))

Thanks for your help.

2 Likes

It is correct, but that uses radians.
Use the math.rad function like this to convert radians to degrees:

p:SetPrimaryPartCFrame(p.CFrame * CFrame.Angles(0,math.rad(180),0))

Have a nice day!

1 Like

I seem to be getting the following error:

CFrame is not a valid member of Model

1 Like

It is not model.CFrame = ...
It is:

model:SetPrimaryPartCFrame(p.CFrame * CFrame.Angles(0,math.rad(180),0))
1 Like

I have this

p:SetPrimaryPartCFrame(p.CFrame * CFrame.Angles(0,math.rad(180),0))

in the script. Isn’t it identical to what you’re putting?

Ohh.
p.CFrame does not work.

it is this: p:SetPrimaryPartCFrame(p.PrimaryPart.CFrame * CFrame.Angles(0,math.rad(180),0))

Yeah I was not paying attention to that part. That should work perfectly.

2 Likes

Ohh, that makes sense. The model doesn’t actually have the capability to have the CFrame.

Thank you very much…

1 Like

how to get rotation value from model`s primary part?