Need help with script (vehicle random position spawn)

When spawning a vehicle, I would like to have it spawning randomly from one, two, three of the vehicle spawn positions.

Put all the Vector3/position of cars inside a table.

local tab = {
   Vector3.new(100, 100, 10),
   Vector3.new(20, 100, 0)
}

Vehicle.Position = tab[math.random(1, #tab)]
1 Like

21:34:21.795 Position is not a valid member of Model “Workspace.LovelySunLilac’s Car”

Model:PivotTo(CFrame.new(0, 50, 0))

Use the pivot methods to move models.

Need I use CFrame for move models?

Yes, but in the example above the CFrame value is constructed using positional components only.

CFrame.new(0, 50, 0) describes the same world space position as Vector3.new(0, 50, 0).


How cna I fix that red line?

Ohh, I solved it, Clone:PivotTo(tab[math.random(1, #tab)])

#tab)])

Just need to move the square bracket inside.