#my script doesnt work and shows this erorr

10 messages · Page 1 of 1 (latest)

stoic nest
#

hi my script is not working is there something wrong with it
This is the erorr: ServerScriptService.Main.Mob:27: attempt to index nil with 'Start'
here is the code of the module script:
`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
    -- move into workspace
    local newMob = mobExists:Clone()
    newMob.HumanoidRootPart.CFrame = map.Start.CFrame
    newMob.Parent = workspace

    coroutine.wrap(mob.Move)(newMob, map)
else
    warn("Requested mob does not exist: ", name)

end

end

return mob

here is the code of hte main script:
local mob = require(script.Mob)
local map = workspace.Grassland

for i=1, 3 do
mob.Spawn("Zombie", map)
task.wait(1)

end`

olive harbor
#

you used a single tilda ` when blocking your code

#

mainly useful for single lines or referencing a single part of the code within a line of regular text

#

if you're posting an entire script i recommend you do what's in the sticker i posted above

#

with the triple tildas

#
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
        -- move into workspace
        local newMob = mobExists:Clone()
        newMob.HumanoidRootPart.CFrame = map.Start.CFrame
        newMob.Parent = workspace

        coroutine.wrap(mob.Move)(newMob, map)
    else
        warn("Requested mob does not exist: ", name)

    end

end

return mob

here is the code of hte main script:
local mob = require(script.Mob)
local map = workspace.Grassland

for i=1, 3 do
    mob.Spawn("Zombie", map)
    task.wait(1)

end```
#

looks like this

#
newMob.HumanoidRootPart.CFrame = map.Start.CFrame```
#

this is the line the script is erroring on