I'm trying to organize my vectors into a table and I'm unsure what the problem it and why it won't pull out the vectors. Can someone help?
local vector1 = Vector3.new(-40, 50, 30) local vector2 = Vector3.new(20, 60, 30) local vector3 = Vector3.new(100, 60, 30) local vector4 = Vector3.new(200, 60, 30) local vector5 = Vector3.new(90, 40, -20) --local vector6 = --local vector7 = local vectors = {vector1, vector2, vector3, vector4, vector5} while true do wait(math.random(1,10)) game.Workspace.Explosion:Play() explode = Instance.new("Explosion",game.Workspace) explode.BlastPressure = 5 explode.BlastRadius = 20 explode.ExplosionType = "NoCraters" explode.Position = math.random(1,#vectors) end
Take a look at this line:
explode.Position = math.random(1,#vectors)
math.random()
returns a random number, therefore you are setting explode
's position to a random number, not a random Vector3
. The fix is as following:
explode.Position = vectors[math.random(1,#vectors)]
This will set explode
's position to a random Vector3
from the table.