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

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

Asked by 3 years ago

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

Log in to vote
2
Answered by 3 years ago
Edited 3 years ago

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.

0
Can you show me an example of using these? Thanks. Cyroxite 46 — 3y
0
I'm not sure how to actually use them so that's why. Cyroxite 46 — 3y
0
Alright, I'm editing my answer yeah. radiant_Light203 1166 — 3y
Ad

Answer this question