0

I got a problem where in my output it shows this:

ServerScriptService.Main.Mob:28: attempt to index number with 'Spawner'

This is my code:

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

function mob.Move(mob, map)
    -- Get the zombie's Humanoid
    local zombieHumanoid = script.Parent.Humanoid

    -- Create a function to check if the zombie is dead
    local function isZombieDead()
        return zombieHumanoid.Health <= 0
    end

    -- Connect the Humanoid's Died event to the function
    zombieHumanoid.Died:Connect()
        -- Destroy the zombie when it's dead
        script.Parent:Destroy()


end

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

    if mobExists then
        for i=1 , quantity do
            task.wait(0.5)
            local newMob = mobExists:Clone()
            newMob.HumanoidRootPart.CFrame = map.Spawner.CFrame
            newMob.Parent = map.Mob

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

    else
        warn("Requested mob does not exist:", name)
    end
end

return mob

Can someone help me??

I tried to look for the solution but I didn't find a number with Spawner

2
  • 3
    The error tries to tell you that map is a number. Commented Mar 24 at 6:31
  • 1
    Your question is asking how do you fix this script, but the error is where you are using the script. What code is calling mob.spawn? Did you mistakenly call it with mob:spawn? Commented Mar 24 at 13:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.