New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
3

How to keep rotation in a CFrame?

Asked by
RubenKan 3570 Moderation Voter Administrator Community Moderator
6 years ago

When i use a CFrame, it always comes back into a certain rotation, even if i use:

script.Parent.CFrame = CFrame.new(script.Parent.Position) * CFrame.Angles(script.Parent.Rotation)

Can anyone help me / tell me why this does not work?

3 answers

Log in to vote
1
Answered by 6 years ago
local vect = Vector3.new(0,0,0)
script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(vect)
Ad
Log in to vote
0
Answered by
modFrost 130
6 years ago

Below will spin the part around in circles,

script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0,math.rad(2),0)
Log in to vote
0
Answered by 10 months ago

You don't use

script.Parent.CFrame = script.Parent.CFrame.new(part.Position) * CFrame.new() 

You use

script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(script.Parent.Orientation)

If you want it to rotate, you would use

while true do
    script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,math.rad(1),0)
end

And that should do it.

Answer this question