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

Attempt to index local m (a nil value) Fix?

Asked by 5 years ago
Edited 5 years ago

i'm scripting a game for finobe, i'm scripting for a message status thingy and i get

15:46:09.698 - Workspace.Killer:517: attempt to index local 'm' (a nil value) 15:46:09.701 - Stack Begin 15:46:09.702 - Script 'Workspace.Killer', Line 517 15:46:09.703 - Stack End

here's the script (the script may have deprecated things because it is for finobe)

function chooseMap()

    --print(table.maxn(minigames))
    --if table.maxn(minigames) < 1 then
        --refill list
        local maps = {}

        mm = game.Lighting.Maps:GetChildren()
        for i=1,#mm do
            if mm[i].className == "Model" and mm[i]:findFirstChild("PickMe") == nil then
                table.insert(maps,mm[i])
                end
            end
        --end

    if game.Workspace.ChosenMapy.Debounce == "None" then
        local randommultiplier = math.random(80,100)
        local t = .01
        local pick = math.random(1,#maps)
        local times = 0
        while true do  -- The following just makes map picking fun
            SlashSound:play()
            if pick > #maps then
                pick = 1
                end

            local m = (maps[pick]) -- (colors[math.random(1,#colors)])
            displayaMessage("--> " .. m.Name .. " <--",t)
            times = times + 1

            if times > 15 then
                t = t*2
                times = 0
                print("Slower")
                end

            randommultiplier = randommultiplier - 1

            if randommultiplier < 1 then 
            print(maps[pick].Name .. ", " .. m.Name)
            table.remove(maps, pick) --no repeating
            return m 
            end

            pick = pick + 1

            --SlashSound:stop()
            end
        else 

        local m = game.Lighting.Maps:findFirstChild(game.Workspace.ChosenMapy.Debounce)
        return m
        end
    end

while true do


    wait(3)
    if reachForPlayers() == true then
        wait(1)

        if chooserdebounce.Value == false and elevatordebounce == true then
            displayaMessage("The next minigame is being chosen by a player (20 more seconds for him/her to choose)...")
            wait(20)
            noMoreChoosing()
            else
            noMoreChoosing()
            displayaMessage("Choosing a map...")
            end

        local m = chooseMap()
        game.Workspace.ChosenMap.Value = "None"
        displayaMessage(" --> " .. m.Name .. " <-- ") -- sound laggg
        Yay:play()
        wait(.8)
        displayaMessage("-->   " .. m.Name .. "   <--")
        wait(.4)
        displayaMessage(" --> " .. m.Name .. " <-- ")
        wait(.4)
        displayaMessage("-->   " .. m.Name .. "   <--")
        wait(.4) -- Just showing that it picked a map
        displayaMessage(" --> " .. m.Name .. " <-- ")
        wait(.4)
        displayaMessage("-->   " .. m.Name .. "   <--")
        wait(.4)
        displayaMessage(" --> " .. m.Name .. " <-- ")
        wait(.4)
        wait(1)
        displayaMessage("The game will start soon.", 3)
        --Hint(m.Name .. " ~~ Origin: " .. m.Origin.Value .. ".

        wait(1)
        print("Getting teh map")
        m = loadMap(m)
        print("Getting teh players")
        wait(1)

        sp = {}
        local spawns = m:GetChildren()
        for i=1,#spawns do
            if spawns[i].Name == "Spawn" then
                table.insert(sp,spawns[i])
                end
            end

        game.Workspace.Controller.Value = nil

        getWillingPlayers(sp)

        displayaMessage("Ready to survive?")
        wait(2)
        displayaMessage("Go!")
        wait(.5)
0
You have tons of deprecated code, like you're using className when it should be ClassName. And you should NOT be using Lighting as storage. User#19524 175 — 5y
0
because i'm making it for finobe TheEdyGamerTroll23 15 — 5y
0
Not an excuse to use deprecated code. Your code should always be up to date. User#19524 175 — 5y

Answer this question