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

Questions about using Model:SetPrimaryPartCFrame()?

Asked by 3 years ago

So I learned about Model:SetPrimaryPartCFrame() and I have questions about using it. The way im it in a script is like this:


local Model = script.Parent Model:SetPrimaryPartCFrame(Model:GetPrimaryPartCFrame() * CFrame.new(0,0,0))

But I was wondering, how do you directly SET the position and orientation? This script just moves the part but how would I move it to a position and set its orientation?

0
you do that... by giving it a CFrame. this has less to do with the function itself, you should find out how to make a CFrame the way you want to. @0hsa has a good example. Speedmask 661 — 3y

2 answers

Log in to vote
1
Answered by
0hsa 193
3 years ago
Model:SetPrimaryPartCFrame(Model.PrimaryPart.CFrame * CFrame.new(0, 0, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)) --[[ would turn it 90 degrees ]]
Ad
Log in to vote
0
Answered by
Mineloxer 187
3 years ago

:SetPrimaryPartCFrame() is equivalent to setting the CFrame of a part like so:

part.CFrame = CFrame.new()

The difference is that it does it to whatever the primary part of the model happens to be.

I think what you're asking for is how you can change positions and orientations of parts, and this is where CFrames come in. To put it simply, CFrames are information on the position and orientation of parts. You can get a part's position, orientation etc. as well as do math with them, with the help of CFrames.

They do require a bit of math knowledge, but the basics should be relativity easy to understand. Here is the API reference for CFrames that I would suggest to take a look at: https://developer.roblox.com/en-us/api-reference/datatype/CFrame

Answer this question