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

My main script has an error, no output messages, Anybody help me to figure out the error?

Asked by 3 years ago
Edited 3 years ago

Good Afternoon. I am making a game about minigames (the classic.) and my main script refuses to work. I would really be interested in some help if you have time...

==script==

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local players = game:GetChildren("Players")
local AllPlayers = game.Players:GetChildren()
local Maps = ReplicatedStorage:WaitForChild("Maps")
local AllMaps = Maps:GetChildren()
local MapSelected = workspace:WaitForChild("MapSelected")
local PCount = workspace:WaitForChild("Players")
local Message = workspace:WaitForChild("Message")
local Time = workspace:WaitForChild("Time")
local Lobby = workspace:WaitForChild("Lobby")
local LobbySpawns = Lobby.Spawns:GetChildren()
local CurrentMap = workspace:WaitForChild("CurrentMap")
local Picked = math.random(1,#AllMaps)
local PlayersNeeded = 2
local winners = {}
local choices = {}

function checkPlayer()
    if PCount.Value >= PlayersNeeded then
        return true
    else
        return false
    end

end

function Intermission()
    for i = 5,1,-1 do
        wait(1)
        Message.Value = "Intermission: "..i.."second(s)"
    end
end

function SelectMap()
    for i = 1,#AllMaps do
        if AllMaps[i]:isA("Model") then
            table.insert(choices,AllMaps[i])
        end
    end
    MapSelected.Value = choices[Picked].Name
    Message.Value = "Minigame Selected: "..MapSelected.Value.."!"
end

function CloneMap()
    local clone = Maps:FindFirstChild(MapSelected.Value):Clone()
    clone.Parent = CurrentMap
end

function ClearMap()
    CurrentMap:ClearAllChildren()
end

function TeleportPlayerToMap()
    for i = 1,#AllPlayers do
        if AllPlayers[i]:WaitForChild("Settings").AFK.Value ~= true then
            if AllPlayers[i].Character ~= nil then
                if AllPlayers[i].Character:FindFirstChild("Humanoid").Health ~= 0 then
                    local spawns = CurrentMap:FindFirstChild(MapSelected.Value):FindFirstChild("Spawns"):GetChildren()
                    if spawns ~= nil then
                        local ransp = spawns[math.random(1,#spawns)].CFrame + Vector3.new(0,3,0)
                        AllPlayers[i].Character.HumanoidRootPart.CFrame = ransp
                        wait()
                        if AllPlayers[i] ~= nil then
                            if AllPlayers[i].Character ~= nil then
                                AllPlayers[i].Character.HumanoidRootPart.CFrame = ransp
                            end
                        end
                        wait()
                        if AllPlayers[i] ~= nil then
                            if AllPlayers[i].Character ~= nil then
                                AllPlayers[i].Character.HumanoidRootPart.CFrame = ransp
                            end
                        end
                    end
                end
            end
        end
    end
end

function KillAllPlayer()
    for i = 1,#AllPlayers do
        AllPlayers[i]:LoadCharacter()
    end
end

function WillingPlayers()
    local n = 0
    for i = 1,#AllPlayers do
        if AllPlayers[i] ~= nil then
            if AllPlayers[i].Setings.AFK.Value ~= true then
                if AllPlayers[i].Character ~= nil then
                    n = n + 1
                end
            end
        end
    end
    return n
end

function AnnounceWinners()
    --b
    --b
    --b
    --b
    --a
    --a
    if MapSelected.Value == "TwistedTemple" then
        for i = 1,#AllPlayers do
            if AllPlayers[i]:WaitForChild("Settings"):WaitForChild("Playing").Value == true then
                table.insert(winners,AllPlayers[i])
                if #winners == 1 then --Needs at least 1 winner. if there is only 1, put the name on it lol.
                    Message.Value = AllPlayers[i].Name.."Won the minigame!"
                    wait(2)
                    AllPlayers[i]:WaitForChild("RCreds").Value = AllPlayers[i]:WaitForChild("RCreds").Value + 200 --Reward cuz it wont be fun if there isnt. please anticheat. PLEASE
                    AllPlayers[i]:WaitForChild("RVictories").Value = AllPlayers[i]:WaitForChild("RCreds").Value + 10 --Reward cuz it wont be fun if there isnt. please anticheat. PLEASE
                elseif #winners >= 2 then
                    Message.Value = "Multiple People Have Won..."
                    wait(2)
                    AllPlayers[i]:WaitForChild("RCreds").Value = AllPlayers[i]:WaitForChild("RCreds").Value + 200 --Reward cuz it wont be fun if there isnt. please anticheat. PLEASE
                    AllPlayers[i]:WaitForChild("RVictories").Value = AllPlayers[i]:WaitForChild("RVictories").Value + 10 --Reward cuz it wont be fun if there isnt. please anticheat. PLEASE

                end
            else 
                Message.Value = "GAME OVER, NOBODY HAS WON."
                wait(2)

            end
        end
        --now for OPT 2
    elseif MapSelected.Value == "LavaJumps" or MapSelected.Value == "SquareParty" then
        for i = 1,#AllPlayers do
            if AllPlayers[i]:WaitForChild("Settings"):WaitForChild("Winner").Value == true then
                table.insert(winners,AllPlayers[i])
                if #winners == 1 then
                    Message.Value = AllPlayers[i].Name.."Has Won The Minigame!"
                    wait(2)
                    AllPlayers[i]:WaitForChild("RCreds").Value = AllPlayers[i]:WaitForChild("RCreds").Value + 500 --Reward cuz the game won't be fun. of there isn't
                    AllPlayers[i]:WaitForChild("RVictories").Value = AllPlayers[i]:WaitForChild("RVictories").Value + 10
                elseif #winners >= 2 then
                    Message.Value = "Multiple People Have Won..."
                    wait(2)
                    AllPlayers[i]:WaitForChild("RCreds").Value = AllPlayers[i]:WaitForChild("RCreds").Value + 200 --Reward cuz it wont be fun if there isnt. please anticheat. PLEASE
                    AllPlayers[i]:WaitForChild("RVictories").Value = AllPlayers[i]:WaitForChild("RVictories").Value + 10
                end
            else
                Message.Value = "No one won. Sad times buddies."
                -- so basically we can only used "Winner"

            end
        end
    end
end

function StartGame()
    ClearMap()
    Intermission()
    wait(2)
    Message.Value = "Choosing The Minigame, Prepare yourself!"
    wait(2)
    SelectMap()
    wait(3)
    Message.Value = "The Map Is Loading!"
    CloneMap()
    wait(4)
    Message.Value = "LET'S GO!"
    wait(1)
    TeleportPlayerToMap()
    wait(3)
    for i = 3,1,-1 do
        wait(1)
        Message.Value = "The Minigame will start in "..i.."second(s)!"
    end
    wait()
    if MapSelected.Value == "SquareParty" then
        for i = 1,#AllPlayers do
            if AllPlayers[i] ~= nil then
                if AllPlayers[i].Settings.AFK.Value == true then
                    AllPlayers[i].Settings.Playing.Value = true
                    AllPlayers[i].Settings.Victorious.Value = true --if only they died, it's false. lol
                    Time.Value = 60 --THE TIME OF THE MINIGAME. Mine's 1 minute
                    CurrentMap:FindFirstChild(MapSelected.Value).MainScript.Disabled = false
                    Time.Script.Disabled = false
                end
            end
        end
    elseif MapSelected.Value == "LavaJumps" then
        for i = 1,#AllPlayers do
            if AllPlayers[i] ~= nil then
                if AllPlayers[i].Settings.AFK.Value == true then
                    AllPlayers[i].Settings.Playing.Value = true
                    Time.Value = 40 --THE TIME OF THE MINIGAME. 
                    CurrentMap:FindFirstChild(MapSelected.Value).MainScript.Disabled = false
                    Time.Script.Disabled = false
                end
            end
        end
    elseif MapSelected.Value == "Twisted Temple" then
        for i = 1,#AllPlayers do
            if AllPlayers[i] ~= nil then
                if AllPlayers[i].Settings.AFK.Value == true then
                    AllPlayers[i].Settings.Playing.Value = true
                    Time.Value = 60 --THE TIME OF THE MINIGAME.
                    CurrentMap:FindFirstChild(MapSelected.Value).MainScript.Disabled = false
                    Time.Script.Disabled = false
                end
            end
        end
    end
    while Time.Value ~= 0 do
        wait()
        if MapSelected.Value == "SquareParty" then
            for i = 1,#AllPlayers do
                if AllPlayers[i] ~= nil then
                    if AllPlayers[i].Settings.AFK.Value ~= true then
                        if AllPlayers[i].Settings.Playing.Value == false then
                            if AllPlayers[i].Settings.Winner.Value == false then
                                Time.Value = 0
                                Time.Script.Disabled = true
                                Message.Value = "TIME'S UP!"
                                wait(2)
                            end
                        end
                    end
                end
            end
            --option 2
        elseif MapSelected.Value == "LavaJumps" or MapSelected.Value == "TwistedTemple" then
            for i = 1,#AllPlayers do
                if AllPlayers[i] ~= nil then
                    if AllPlayers[i].Settings.AFK.Value ~= true then
                        if AllPlayers[i].Settings.Playing.Value == false and AllPlayers[i].Settings.Winner.Value == false then
                            Time.Value = 0
                            Time.Script.Disabled = true
                            Message.Value = "TIME'S UP!"
                            wait(2)
                        end
                    end
                end
            end
        end
    end
    table.remove(choices,Picked)
    table.remove(winners)
end

while true do
    wait(3)
    if checkPlayer()then
        if WillingPlayers() >= PlayersNeeded then
            StartGame()
        elseif WillingPlayers() <= PlayersNeeded then
            Message.Value = PlayersNeeded.." or more players needed."
        end
    elseif not checkPlayer()then
        Message.Value = PlayersNeeded.." or more players needed."
    end
end

Personally, my theory is that the same mistake is made in different lines, like a duplicate of the same mistake.

There are unfortunately no output messages.

0
Help is needed, so it would be appreciated. EmmaMallen 13 — 3y

Answer this question