Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Unable to cast double Vector3?

Asked by 9 years ago

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

Log in to vote
0
Answered by 9 years ago
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
0
Thank you so much! I understand why it didn't work! THANKS yogipanda123 120 — 9y
Ad

Answer this question