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

How would i make a model rotate 90 degrees to the right?

Asked by 7 years ago
Edited 7 years ago

How would i make a model rotate 90 degrees to the right when i press r.
here is what i have already:

PlayerMouse.KeyDown:connect(function(key)
    if key == "r" then
        if Clone.MovedValue.Value == false then
            local model = Clone.Model
            model.PrimaryPart = model.Center1
            local cframe = model.PrimaryPart.CFrame -- Current CFrame
            model:SetPrimaryPartCFrame(cframe * CFrame.new(0, math.rad(90), 0))
        end
    end
end)

So far it moves it up and doesn't rotate.

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago

You can multiply by the CFrame.Angles constructor in order to orientate the model.

local cframe = model.PrimaryPart.CFrame

model:SetPrimaryPartCFrame(cframe * CFrame.Angles(0, math.rad(90), 0))
0
It works but it keeps on changing the direction it rotates any ways i can fix this? justintubba123 6 — 7y
0
If I understand the issue correctly, you should add a debounce. Goulstem 8144 — 7y
Ad

Answer this question