Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would you add value to CFrame?

Workspace.Part1.CFrame = Workspace.Part1.CFrame * CFrame.Angles(0,math.rad(10),0)

This only sets it to that degree. + CFrame.Angles(0,math.rad(10),0) wont work it tells me it needs a vector 3, which I tried and wouldn't work either.

What I plan on doing is adding +1 to math.rad (10) every 1 second. If I do this:

Workspace.Part1.CFrame = Workspace.Part1.CFrame * CFrame.Angles(0,math.rad(10),0)
wait(1)
Workspace.Part1.CFrame = Workspace.Part1.CFrame * CFrame.Angles(0,math.rad(10),0)

It'll stay at 10, not move on to 11.

3 answers

✓ Accepted answer

You can use the addition operator, + between a CFrame and a Vector3, between a Vector3 and another Vector3 but not between a CFrame and another CFrame - the Offical ROBLOX Wiki page on CFrames has a section devoted to explaining the CFrame Operators.

Because of the way matrix math works (which is what CFrames effectively are) a multiplication has an additive affect, so:

part.CFrame = part.CFrame * CFrame.Angles(0,math.rad(10),0)
part.CFrame = part.CFrame * CFrame.Angles(0,math.rad(10),0)

Does exactly the same transformation as:

part.CFrame = part.CFrame * CFrame.Angles(0,math.rad(20),0)

If you do use the + operator with a CFrame, you must use it in conjunction with a Vector3 - this will work, if it does not, you are doing something wrong and would need to show us what it is for us to help :)

4 comments

0

Haha, I didn't realise it was you until I'd posted my answer - let me know if you need anything else explaining, I don't think I understood your question entirely.

0

Lol hey! Btw I tried CFrame.Angles(0,math.rad(10),0) twice, it doesn't rotate to 20, it just stays at 10

0

BTW I updated the question.

0

NVM, It works now. I have no clue what was wrong. Thanks though.

Workspace.Part1.CFrame = CFrame.new(--[[X Axis]],--[[Y Axis]],--[[Z Axis]]) * CFrame.Angles(0,math.rad(10),0)

You would put the position vector in the CFrame.new() parenthesis, just like you would with a Vector3.new()

1 comment

0

I don't need to change the position. Just adding +1 on the Y axis rotation value.

Workspace.Part1.CFrame = CFrame.new(Workspace.Part1.CFrame * CFrame.Angles(0,math.rad(10), 0))

I believe is correct.

3 comments

0

Same Error.

0

Sorry about that I havn't used CFrame in a while. Editted it.

0

It might be what TurboFusion said. Like I said I havn't used CFrame in a while.

This discussion is preserved as it was. New answers, comments, and votes are closed.