I am making a script, it spawns enemies in waves! It works the first time... but after that I get an error saying "Unable to cast double Vector3"! Here is my script
function goSpawn() local posx = math.random(-254,254) local posz = math.random(44,255) local larva = game.ReplicatedStorage.Alien:clone() larva.Parent = workspace larva:MoveTo(posx,5,posz) end if script.Parent.WaveCount.Value == 1 then wait(5) goSpawn() wait(1) goSpawn() wait(1) goSpawn() wait(1) goSpawn() wait(1) goSpawn() wait(1) goSpawn() wait(1) goSpawn() wait(1) goSpawn() wait(1) goSpawn() wait(1) goSpawn() end
Please help!!! Thank you!!!
local AmountOfWaves = 10 -- How many waves do you want? Put them here local TimePerWave = 1 -- How long you want to wait per wave local WaveCount = script.Parent.WaveCount -- I suppose you're doing something with this local function SpawnWave() local Bot = game.ReplicatedStorage.Alien:Clone() Bot.Parent = Workspace Bot:MoveTo(Vector3.new(math.random(-254,254), 5, math.random(44,255))) end for CurrentWave = 1, AmountOfWaves do SpawnWave() Wait(TimePerWave) end