How to properly store Vector3's in a table?

Hello, I was trying to position a part randomly from a table, and I noticied my script only changes the first Axis. I think the commas that seperate the axis mess the table up, how do I store them properly?
Is there a way to do it for all the axis in my table?

local positions = {
	6.93, 0.5, 33.16,
	18.71, 0.5, 35.57,
	-15.27, 0.5, 23.67
}

local part = script.Parent

function movePart()
	part.Position = Vector3.new(positions[math.random(1,#positions)])
end

while true do
	wait(1)
	movePart()
end 

Heres what I didn’t expect to happen:
https://i.gyazo.com/5e2d0b52b276690188572aba394d0e78.mp4

If you can help then thanks

local positions = {
	Vector3.new(6.93, 0.5, 33.16);
	Vector3.new(18.71, 0.5, 35.57);
	Vector3.new(-15.27, 0.5, 23.67);
}
4 Likes

If you don’t want to store them as Vector3, then store them as tables, for example: 1, 0, 1 to {1, 0, 1}

And at the movePart()

local Pos = positions[math.random(1,#positions)]
part.Position = Vector3.new(Pos[1], Pos[2], Pos[3])
2 Likes

If you want an explanation why it didn’t work: It didn’t work for you before because you didn’t make them a Vector3 value, so you have actually just chosen some number (for example 0.5) and you positioned it there, but Vector3 needs 3 arguments (X, Y, Z) so that’s why it didn‘t work. (I am bad at explaining sorry if you don’t understand that.)

1 Like