Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Unable to cast double Vector3?

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!!!

1 answer

✓ Accepted answer
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

1 comment

0

Thank you so much! I understand why it didn't work! THANKS

This discussion is preserved as it was. New answers, comments, and votes are closed.