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

Why does this error after loading a map?

Asked by 10 years ago

Everything loads like it should but... after loads at 50% its someways errors. :/??? Umm I have tryed a lot of different codes for it but nothing worked yet.

Output = {
10:19:06.511 - ServerScriptService.Map:103: attempt to call a nil value
10:19:06.512 - Stack Begin
10:19:06.513 - Script 'ServerScriptService.Map', Line 103 - global LoadMap
10:19:06.514 - Script 'ServerScriptService.Map', Line 138
10:19:06.514 - Stack End
}

(Its a HUGE map) I believe the error is when it trying to find the Gui again and cant because of the Map Generaton lag.

Settings={
    MapLoad={
        ['Map1']={Loaded=true,Pos=game.ServerStorage.Maps['Map1']};
        ['Map2']={Loaded=false,Pos=game.ServerStorage.Maps['Map2']};
        ['Map3']={Loaded=false,Pos=game.ServerStorage.Maps['Map3']};
        ['Map4']={Loaded=false,Pos=game.ServerStorage.Maps['Map4']};
        ['Map5']={Loaded=false,Pos=game.ServerStorage.Maps['Map5']};
        ['Map6']={Loaded=false,Pos=game.ServerStorage.Maps['Map6']};
        ['Map7']={Loaded=false,Pos=game.ServerStorage.Maps['Map7']};
        ['Map8']={Loaded=false,Pos=game.ServerStorage.Maps['Map8']};
    };  
    ---------------
    ['ToggleMusic']=true;
    ---------------------
    ['Baned']={
 --Dont ask lol
    };
    ['GamePass']={
        ['Tips']=176040344;
        ['Vip']=176040913;
    };
    ['QuickLoad']={
        134351045;
        133452074;
        159770009;
        153851899;
        145516026;
        144938735;
        180243088;
        143382469;
        177259535;
        148101943;
        154090296;
    };
    ['Sounds']={
        ['Error']=134351045;
        ['Lose']=133452074;
        ['Win']=159770009;
        ['Lobby']=153851899;
        ['S1']=145516026;
        ['S2']=144938735;
        ['S3']=180243088;
        ['S4']=143382469;
        ['S5']=177259535;
        ['S6']=148101943;
        ['S7']=154090296;
        ['S8']=131064127;
    };
    ['Tools']={
        Ak47=game:GetService('ServerStorage')['AK47'];
        MachineGun=game:GetService('ServerStorage')['Sub Machine Gun'];
        Knife=game:GetService('ServerStorage')['Blade'];
        Shotgun=game:GetService('ServerStorage')['Dual Shotguns'];
        FlashLight=game:GetService('ServerStorage')['Flashlight'];
        MainGun=game:GetService('ServerStorage')['9mm'];
    };
    ['Services']={
        Load=game:GetService("ContentProvider");
        Pass=game:GetService("GamePassService");
        Storage=game:GetService("ServerStorage");
        Pack=game:GetService("Backpack");
        Http=game:GetService("HttpService");
        Teams=game:GetService("Teams");
        TP=game:GetService("TeleportService");
    };
};

for _, assetId in pairs(Settings.QuickLoad) do Settings.Services.Load:Preload("http://www.roblox.com/asset/?id=" .. assetId) end

game.Players.PlayerAdded:connect(function(Plr) if Plr.Name==(Settings.Baned)[Plr.Name] then wait() Plr:Kick() end end)

function NewSound(Txt) game.workspace.Sound:Pause() wait() game.workspace.Sound.SoundId=('rbxassetid://'..Txt) wait() game.workspace.Sound.Looped=true wait() game.workspace.Sound:Play() end

function GuiNote(Txt)
    for _, Plr in pairs(game.Players:GetPlayers()) do
        local gui=Plr:FindFirstChild('PlayerGui')
        wait()
        gui.Note.Frame.TextLabel.Text=(Txt)
    end
end

function LoadTools()
    for _, Plr in pairs(game.Players:GetPlayers()) do
    if (Settings['Services']).Pass:PlayerHasPass(Plr,Settings.GamePass.Vip) then
        Settings.Tools.Knife:Clone().Parent=(Plr:FindFirstChild("Backpack")) wait()
        Settings.Tools.Ak47:Clone().Parent=(Plr:FindFirstChild("Backpack")) wait()
        Settings.Tools.Shotgun:Clone().Parent=(Plr:FindFirstChild("Backpack")) wait()
        Settings.Tools.MachineGun:Clone().Parent=(Plr:FindFirstChild("Backpack")) wait()
        Settings.Tools.FlashLight:Clone().Parent=(Plr:FindFirstChild("Backpack"))
        Settings.Tools.MainGun:Clone().Parent=(Plr:FindFirstChild("Backpack"))
    elseif (Settings['Services']).Pass:PlayerHasPass(Plr,Settings.GamePass.Tips) then
        Settings.Tools.Knife:Clone().Parent=(Plr:FindFirstChild("Backpack")) wait()
        Settings.Tools.FlashLight:Clone().Parent=(Plr:FindFirstChild("Backpack"))
        Settings.Tools.MainGun:Clone().Parent=(Plr:FindFirstChild("Backpack"))
    else
        Settings.Tools.MainGun:Clone().Parent=(Plr:FindFirstChild("Backpack"))
    end 
    end
end

function GetTeleport()
    for _, Plr in pairs(game.Players:GetPlayers()) do
        if (Settings['MapLoad']).Map1.Loaded==true then Plr.Character:MoveTo(Vector3.new(2919.851, 933.93, -660.829)) elseif (Settings['MapLoad']).Map2.Loaded==true then Plr.Character:MoveTo(Vector3.new(3112.31, 794.92, -489.69)) elseif (Settings['MapLoad']).Map3.Loaded==true then Plr.Character:MoveTo(Vector3.new(2896.31, 859.66, -741.727)) elseif (Settings['MapLoad']).Map4.Loaded==true then Plr.Character:MoveTo(Vector3.new(2764.62, 833.48, -424.78)) elseif (Settings['MapLoad']).Map5.Loaded==true then Plr.Character:MoveTo(Vector3.new(2210.21, 855.11, -566.4)) elseif (Settings['MapLoad']).Map6.Loaded==true then Plr.Character:MoveTo(Vector3.new(2205.61, 888.18, -478.27)) elseif (Settings['MapLoad']).Map7.Loaded==true then Plr.Character:MoveTo(Vector3.new(2811, 927.15, -274.78)) elseif (Settings['MapLoad']).Map8.Loaded==true then Plr.Character:MoveTo(Vector3.new(2743.25, 1003.48, -232.06))
        end
        end
end

function LoadMap()
GuiNote('Loading Map..[0%]') wait(1) GuiNote('Loading Map..[10%]') wait(1) GuiNote('Loading Map..[15%]') wait(1) GuiNote('Loading Map..[50%]')
if (Settings['MapLoad']).Map1.Loaded==true then LoadTools() NewSound(Settings.Sounds.S1) (Settings['MapLoad']).Map1.Pos:clone().Parent=(workspace) else end
if (Settings['MapLoad']).Map2.Loaded==true then LoadTools() NewSound(Settings.Sounds.S2) (Settings['MapLoad']).Map2.Pos:clone().Parent=(workspace) else end
if (Settings['MapLoad']).Map3.Loaded==true then LoadTools() NewSound(Settings.Sounds.S3) (Settings['MapLoad']).Map3.Pos:clone().Parent=(workspace) else end
if (Settings['MapLoad']).Map4.Loaded==true then LoadTools() NewSound(Settings.Sounds.S4) (Settings['MapLoad']).Map4.Pos:clone().Parent=(workspace) else end
if (Settings['MapLoad']).Map5.Loaded==true then LoadTools() NewSound(Settings.Sounds.S5) (Settings['MapLoad']).Map5.Pos:clone().Parent=(workspace) else end
if (Settings['MapLoad']).Map6.Loaded==true then LoadTools() NewSound(Settings.Sounds.S6) (Settings['MapLoad']).Map6.Pos:clone().Parent=(workspace) else end
if (Settings['MapLoad']).Map7.Loaded==true then LoadTools() NewSound(Settings.Sounds.S7) (Settings['MapLoad']).Map7.Pos:clone().Parent=(workspace) else end
if (Settings['MapLoad']).Map7.Loaded==true then LoadTools() NewSound(Settings.Sounds.S8) (Settings['MapLoad']).Map8.Pos:clone().Parent=(workspace) else end
wait(1) GuiNote('Loading Map..[75%]') wait(1) GuiNote('Loading Map..[75%]') wait(1)  GuiNote('Loading Map..[85%]') wait(1)  GuiNote('Loading Map..[100%]') wait(1)  GuiNote('[Teleporting..]') wait() GetTeleport()
end

function LoadSync(Txt)
print((Settings['Services']).Http:GetAsync(Txt))
end

function Respawn()
 for _, Plr in pairs(game.Players:GetPlayers()) do
Plr:LoadCharacter()
end
end

game.Players.PlayerAdded:connect(function()
NewSound(Settings.Sounds.Lobby)
wait()
GuiNote('Waiting for Assets To Load...')
if game.workspace:WaitForChild('Sound') and game.ServerStorage:WaitForChild('Maps') and game.StarterGui:WaitForChild('DoorOpener') and game.StarterGui:WaitForChild('Note') and game.StarterGui:WaitForChild('Time') then
wait(7)
GuiNote('Starting Game...[5]') wait(1) GuiNote('Starting Game...[4]') wait(1) GuiNote('Starting Game...[3]') wait(1) GuiNote('Starting Game...[2]') wait(1) GuiNote('Starting Game...[1]') wait(1) GuiNote('Starting Game...[0]') wait() LoadMap()
else
end
end)

Answer this question