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

How do I make a Model roate with a Script? [closed]

Asked by 7 years ago
Edited 7 years ago

This question already has an answer here:

Rotating a model?

So i'm trying to make a script that rotates a model, But I don't exactly know how to do so. Does anyone know how to do it?

0
Please remember to search before asking non-specific questions.. chances are it has already been asked. Goulstem 8144 — 7y
0
+1 so you don't lose rep when I moderate Goulstem 8144 — 7y

Marked as Duplicate by Goulstem

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

1 answer

Log in to vote
1
Answered by 7 years ago

Well, to do this, you'll want to use SetPrimaryPartCFrame() which is pretty easy to used when you learn it. If you want to rotate the model, you would do this:

workspace.Model:SetPrimaryPartCFrame(workspace.Model.MyPrimaryPart.CFrame * CFrame.Angles(math.rad(15), math.rad(90), math.rad(0)))
--math.rad() turns numbers into radians, incase you didn't know.

Now, if you want to create a spinning part, do this:

game:GetService("RunService").RenderStepped:connect(function()
    workspace.Model:SetPrimaryPartCFrame(workspace.Model.MyPrimaryPart.CFrame *                                                                 CFrame.Angles(math.rad(15), math.rad(90), math.rad(0)))
end

This works by adding to the models rotation every render frame (about 1/60 of a second) instead of just the first time we run the code.

Also, keep in mind that MyPrimaryPart is the name of the model's primary part, which can be set in it's properties tab.

Hope this helps :)

Ad