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

How to access specific parts of a Vector3/RGB Value?

Hi there guys.

My question that I've been thinking about is how to access one of the 3 values found in a Vector3 /RGB value. Sure, you can add or subtract values with CFrame or name these 3 values in a variable beforehand, but what I want to do is some thing like this:

local RGB= Color3.fromRGB(23,46,69)
--Make a variable that gets the first value
--Make a variable that gets the second value
--Make a variable that gets the third value

I've looked into the object browser for any functions to this, but I can't find anything.

Thanks.

1 answer

✓ Accepted answer

For Vector3s you can do Vector.X, Vector.Y, Vector.Z. For Colour3s you can do Colour.R, Colour.G and Colour.B.

Short answer.

local newVector = Vector3.new(10, 20, 30)
part.Position = Vector3.new(newVector.X, newVector.Y, 40)

Basically, I positioned a part using only the X and Y components of newVector but used 40 (instead of 30) for the Z coordinate.

3 comments

0

Can you show me an example of using these? Thanks.

0

I'm not sure how to actually use them so that's why.

0

Alright, I'm editing my answer yeah.

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