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

How can I place CFrames in an array? [Solved]

Asked by 10 years ago

I would like to place CFrames in an array, but I can't place commas in the array without separating my value into pieces. This code shows my problem:

local myArray = {0, 5, 0, 100, 6, 2}

"0, 5, 0" is my first coordinate, "100, 6, 2" is my second. I can't get these coordinates to be shown as two values instead of six. Any help in resolving this issue is greatly appreciated.

2
Maybe try this? local myArrary = {CFrame.new(0,5,0), CFrame.new(100,6,2)} I have never tried this before so I'm not sure. Perci1 4988 — 10y

1 answer

Log in to vote
1
Answered by
Nifer2 174
10 years ago
local myArray = {0, 5, 0, 100, 6, 2}

print(myArray[1]) -- You use myArray[numberhere] to select a part of the array.
print(myArray[1] + "," + myArray[2] + "," + myArray[3] -- This should print 0,5,0.

When you want to select a specific part of an array, you use Array[numberhere] to select a specific part. There's also another idea I have which may help you, but I'm not sure if you'll like it because it involves using strings in the array.

local myArray = {"0, 5, 0", "100, 6, 2"}

print(tonumber(myArray[1])) -- This turns the first object of myArray into a number. The object was originally string.
print(tonumber(myArray[2])) -- This turns the second object of myArray into a number. This was also a string. Should print 100, 6, 2.
Ad

Answer this question