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

[string "local maps = {"Round"};..."]:5: attempt to index global 'game' (a nil value)?

Asked by 5 years ago
Edited 5 years ago

I need to get better at scripting lol.

local maps                    = {"Round"};
local Positions               = {};
local Winners                 = {};

local Players                 = game:GetService('Players');
local ReplicatedStoragge      = game:GetService('ReplicatedStorage');
local text                    = "Waiting for players.....";
local intermission            = 1;
local timebeforeroundstarts   = 5;
local Roundwait       = 6;
local Remotes                 = ReplicatedStoragge:WaitForChild('Remotes');
local CountDown               = Remotes:WaitForChild('Countdown');

local function m(update)
    local c = game.Players:GetChildren();

    for i=1, #c do
        c[i].PlayerGui.InformationGui.loltext.Text = "" .. update;
    end;
end;

local function FindIndex(Table,Val)
    for index,v in pairs(Table) do
        if v == Val then
            return index;
        end;
    end;
end;


while wait() do
    if #Players:GetPlayers() >= 5 then
        wait();
        for i=1, intermission do
            m("Intermission: " .. intermission - i);
 if #Players:GetPlayers() < 5 then
     m("Waiting for Players...");
        end;
end;

        local gtl = game.Players:GetChildren();

        for i=1, #gtl do
            gtl[i].Playing.Value = true;
        end;

        local mapnum = #maps;
        local map = maps[mapnum];
        game.Lighting[map]:Clone().Parent = workspace;
        m("Game Starting...");
        wait(3);

        m("Game Starting...");
        wait(2);

        for i=1, timebeforeroundstarts do
        m("The game will start in: " .. timebeforeroundstarts -i);
            wait(1);
        end;

        local getall = game.Players:GetChildren();
        local getspawns = game.Workspace[map].Spawns:GetChildren();

        for i=1, #getall do
            if getall[i].Playing.Value == true then
                curspawn = game.Workspace[map].Spawns.Spawn;
                getall[i].Character.Torso.CFrame = CFrame.new(curspawn.Position);
                curspawn:remove();
            end;
        end;

        if map == "Round" then
            for i=1, Roundwait do
                m("The game will end In: " .. Roundwait -i);
                wait(1);
            end;
        end;

        local getllas = game.Players:GetChildren();

        for i=1, #getllas do
            if getllas[i]:FindFirstChild("leaderstats") then
                if getllas[i].Playing.Value == true then
                    getllas[i].leaderstats.Wins.Value = getllas[i].leaderstats.Wins.Value + 1;
                    getllas[i].leaderstats.Points.Value = getllas[i].leaderstats.Points.Value + 10;
                    table.insert(Winners, getllas[i].Name);
                end;
            end;
        end;

        if #Winners == 0 then
            m("Nobody Won!")
        else
            m(table.concat(Winners, ", ").." Has won!");
        end;

        game.Workspace[map]:Destroy();

        for i=1, #Winners do
            table.remove(Winners, 1);
        end;
    end;
end;
1
You space out your code that much on lines 1-12? That’s the error. And what’s with the semicolons? You can’t add things to your script just because you feel like it. That’s another reason it errors! User#19524 175 — 5y
1
^ No it doesn't. Zafirua 1348 — 5y
0
battle of the scripters sweetlittlegirlohhl -22 — 5y
0
^^zafirua lmao User#19524 175 — 5y
View all comments (2 more)
0
what? Zafirua 1348 — 5y
1
Spacing is not the reason for the error, ever. You could add all the whitespace you want and nothing will error. oreoollie 649 — 5y

Answer this question