This sounds very confusing at first, and to be honest I’m not sure if it’s even possible to do.
this sets up a function, basic randomizer
function randomizer(yourTable)
local n = math.random(1, #yourTable)
local thing = yourTable[n]
return thing
end
this script utilizes that and tries to basically set A to a random thing from the table, and remove the result from the table after it is chosen (to prevent duplicates, you know)
local positionTables = {Vector3.new(0,0,64), Vector3.new(0,0,-64), Vector3.new(64,0,0), Vector3.new(-64,0,0)}
local A = randomizer(positionTables)
table.remove(positionTables, A) --erroring line
on the erroring line, it is quite obvious- im giving it a vector3 instead of a number, being its position and all
so my question is, how can i get the index from an array value (the vector3)?
local array = {
1,
2,
3,
4,
5
}
array[3] = nil
-- Now, the index 3 is the gap in the array. table.remove re shifts everything to remove that gap, so you shouldn't have any issues.
-- Also,
-- #array == 2 because that's the "highest index", that has no gap until it