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

How to use a CFrameValue?

Asked by
RoboFrog 400 Moderation Voter
10 years ago

In this post, I'm talking about the CFrameValue value, not just the theoretical value set inside of scripts.

I've checked the wiki, but since the most recent update, it's largely useless when it comes to learning about these more obscure RBX.Lua items. I'd like to know the following things --

  • How do I store values inside of them?

    • Assuming it's the same way as other variables, should it be in the form (0, 0, 0), Cframe.new(0,0,0), or something else?
    • Also, could I store values into them by calling on a part's Position property?
  • What do they return exactly (format and value form) when called upon?

  • Where in my code should I put a reference to it in order for it to register?

    • By this, would I execute it like Cframe.new(cframevalue.Value) or just set the Cframe I'm looking to change to = cframevalue.Value?
  • What are their limitations, if any? (within obvious reason)

If there's anything else you might deem important, please let me know -- even though I'm a generally proficient scripter, I love to be as informed as possible about subjects I know little about.

Thank you for reading, and I look forward to finding what this obscure little element does!

1 answer

Log in to vote
2
Answered by 10 years ago

A CFrame value still does store CFrames, But you dont actually see them in the Property Window. If you are to store a CFrame inside of one, it must be a type of CFrame rather than Vector3 or Vector2. It will store ALL the CFrame stuff any CFrame has, Including rotation. To set it you could do.

workspace.CFValue.Value = Part.CFrame

or for a specific Position:

workspace.CFValue.Value = CFrame.new(0,10,0)

and it will work. Yes you can do something like

part2.CFrame = workspace.CFValue.Value 

instead of doing

part2.CFrame = CFrame.new(workspace.CFValue.Value)

I hope this answered your question.

0
That definitely helps out. However, I'm just curious -- since it can't store Vector values, that does mean Position isn't able to set the value? RoboFrog 400 — 10y
0
Actually, it can. There are multiple ways of doing it. you could do CFValue.Value = CFrame.new(part.Position) That converts it to a CFrame value, but does not exactly store everything. Thats why it is better to save it as Part.CFrame instead Of position. Its just the same, but a little more info. nighttimeninja314 120 — 10y
0
Actually, CFrame.new(part.Position) would probably work perfectly. I don't really want to save the angles, and assuming it'll work the same as a position, is exactly what I need. Thanks! RoboFrog 400 — 10y
0
FYI: part.Position == part.CFrame.p --lowercase `p` adark 5487 — 10y
Ad

Answer this question