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

my minigame status bar gets stuck on loading map. does anyone know how to fix this?

Asked by 7 years ago
Edited 7 years ago

Here is my code for my entire game script. I tried already putting a colon in on line 87 but i could not fix this problem on line 86.

local maps = game.ServerStorage:WaitForChild("Maps"):GetChildren()
local lobby = game.Workspace:WaitForChild("Lobby")
local message = game.Workspace:WaitForChild("Message")
local numplayers = game.Workspace:WaitForChild("NumPlayers")
local chosenmap= game.Workspace:WaitForChild("ChosenMap")
local selected = game.Workspace:WaitForChild("SelectedMap")
local timer = game.Workspace:WaitForChild("Timer")
local playerNeeded = 1 -- for testing :P
local winners = {}

function deleteLastMap()
    selected:ClearAllChildren()
end

function checkPlayers()
    if numplayers.Value >= playerNeeded then
        return true
    else
        return false
    end
end

function getAlivePlayers()
    local n = 0
    local players = game.Players:GetPlayers()
    for i = 1,#players do
        if players[i].Settings.AFK.Value ~= false then
            if players[i].Character ~= nil then
                if players[i].Character.Humanoid.Health ~= 0 then
                    if players[i].Settings.Playing.Value ~= false then
                        n = n + 1
                    end
                end
            end
        end
    end
    return n
end

function getWinners()
    local n = 0
    local players = game.Players:GetPlayers()
    for i = 1,#players do
        if players[i].Settings.AFK.Value ~= false then
            if players[i].Character ~= nil then
                if players[i].Character.Humanoid.Health ~= 0 then
                    if players[i].Settings.Winners.Value ~= false then
                        n = n + 1
                    end
                end
            end
        end
    end
    return n
end

function intermission()
    for i = 2,1,-1 do -- 5 is the time
        wait(1)
        message.Value = "Intermission: "..i.." seconds!"
    end
end

function choosemap()
    message.Value = "Choosing minigame..."
for i = 1,#maps do
    if maps[i]:isA("Model")then
    chosenmap.Value = maps[math.random(1,#maps)].Name
    end
    end
end

function displayChosen()
    message.Value = "Minigame Chosen: "..chosenmap.Value.."!"
end

function loadMinigame()
    message.Value = "Loading map..."..chosenmap.Value.."!"
    local clone = game:GetService("ServerStorage").Maps:FindFirstChild(chosenmap.Value)
    clone:Clone().Parent = selected

end

function startGame()
    local mapspawn = selected:FindFirstChild(chosenmap.Value).Spawns:GetChildren()
    local lobbySpawn = game.Workspace.Lobby.Spawns:GetChildren()
    local players = game:GetService("Players"):GetPlayers()
    message.Value = "Teleporting Players..."
    wait(1)
    for i = 1,#players do
        if players[i] ~= nil then
            if players[i].Settings.AFK.Value ~= false then
                if players[i].Character ~= false then
                    if players[i].Character.Humanoid.Heath ~= 0 then
                        local ransp = mapspawn[math.random(1,#mapspawn)].CFrame + Vector3.new(0,3,0)
                        players[i].Character.HumanoidRootPart.CFrame = ransp
                        wait()
                        if players[i] ~= nil then
 if players[i].Character ~= nil then
  players[i].Character.HumanoidRootPart.CFrame = ransp
 end
end

                    end
                end
            end
        end
    end
wait(2)
for i = 3,1,-1 do
    wait(1)
    message.Value = "The game will start in: "..i.." seconds!"
    end
    wait(1)
    message.Value = "Go!"
    for i = 1,#players do
     if players[i] ~= nil then
        if players[i].Settings.AFK.Value ~= true then
            if players[i].Character ~= nil then
                players[i].Settings.Playing.Value = true
            end
        end

    end
end
    timer.Value = selected:FindFirstChild(chosenmap.Value).Timer.Value
    while timer.Value ~= 0 and getAlivePlayers()~=0 do
    wait(1)
    message.Value = "Time left: "..i.." seconds!"
    timer.Value = timer.Value-1
end
wait(1)
message.Value = "Times Up!"
wait(2)
for i,v in pairs (players) do
    v.Settings.Playing.Value = false
    if v.Settings.Winner.Value == true then
        table.insert(winners.players[i])
        if #winners == 1 then
            message.Value = v.Name.."Won the minigame!"
            wait(2)
            message.Value = "The winner will recieve 50 credits!"
            v.leaderstats.Wins.Value = v.leaderstats.Wins.Value + 1
            v.leaderstats.Credits.Value = v.leaderstats.Credits.Value + 50
        elseif #winners>=2 then
            message.Value = "Multiple players have won the minigame!"
            wait(2)
            message.Value = "both players will recieve 25 credits!"
            v.Settings.Winner.Value = false
            v.leaderstats.Wins.Value = v.leaderstats.Wins.Value + 1
            v.leaderstats.Credits.Value = v.leaderstats.Credits.Value + 25
        end
    end
end
wait(2)
for i = 1,#players do
    if players[i] ~= nil then
        if players[i].Character ~= nil then
            local ransp = lobbySpawn [math.random(1,#lobbySpawn)].CFrame + Vector3.new(0,3,0)
            players[i].Character.HumanoidRootPart.CFrame = ransp
        end
    end
end
end


while true do
    wait()
    if checkPlayers() then
        intermission()
        wait(1)
        choosemap()
        wait(3)
        displayChosen()
        wait(2)
        loadMinigame()
        wait(2)
        if checkPlayers()then
        startGame()
end
table.remove(winners)
deleteLastMap()
    end
end
0
We need to see more of the script to help you out. What calls functions loadMinigame and startGame? Something needs to call both functions for them to execute. Also ... there should be errors on lines 09 and 10 because you used a period instead of a colon to call instance methods (:GetChildren() and :GetPlayers()) User#18718 0 — 7y
0
Thank you i updated my post where i tried the colon on 1 line but the other line i could not figure out how to do lolapus4 9 — 7y

Answer this question