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

please help me i am getting error "attempt to index number with 'Start' "?

Asked by 2 years ago
Edited 2 years ago

Can anyone help me i am making a tower defence simulator and when i spawn more than 1 wave it gives me an error "attempt to index number with 'Start' "

i have a part in the workspace in my folder 'Grassland' which is my map and this is my wave code

local mob = require(script.Mob) local map = workspace.Grassland

for wave=1,2 do print("WAVE STARTING:", wave)

if wave <= 1 then
    mob.Spawn("Zombie", 3 * wave, map)
elseif wave <= 2 then
    mob.Spawn("Zombie", 6, wave, map)
    mob.Spawn("FastZombie", 3, wave, map)
elseif wave == 2 then
    mob.Spawn("Zombie", 100, map)
end

repeat
    task.wait(1)
until #workspace.Mobs:GetChildren() == 0

print("WAVE ENDED")
task.wait(13)

end

and this is my main script

local PhysicsService = game:GetService("PhysicsService") local ServerStorage = game:GetService("ServerStorage") local mob = {}

function mob.Move(mob, map) local humanoid = mob:WaitForChild("Humanoid") local waypoints = map.Waypoints

for waypoint=1, #waypoints:GetChildren() do
    humanoid:MoveTo(waypoints[waypoint].Position)
    humanoid.MoveToFinished:Wait()
end

mob:Destroy()

end

function mob.Spawn(name, quantity, map) local mobExists = ServerStorage.Mobs:FindFirstChild(name)

if mobExists then
    for i=1, quantity do
        task.wait(0.5)
        local newMob = mobExists:Clone()
        newMob.HumanoidRootPart.CFrame = map.Start.CFrame
        newMob.Parent = workspace.Mobs
        newMob.HumanoidRootPart:SetNetworkOwner(nil)

        for i, object in ipairs(newMob:GetDescendants()) do
            if object:IsA("BasePart") then
                PhysicsService:SetPartCollisionGroup(object, "Mob")
            end
        end


        coroutine.wrap(mob.Move)(newMob, map)
    end

else
    warn("Request mob doesnt exists", name)
end

end

return mob

0
dude idk why it is this like that but they are scripts after text Mansimran1235 0 — 2y
0
you have to put the code inside the "~~~~~~~~~" block PaleNoobs 37 — 2y
0
Can you fix the code block by editing, pls? AProgrammR 398 — 2y

Answer this question