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

How would you combine these functions? [closed]

Asked by 10 years ago

I recently created a script, and I need help combining the functions so they don't spam over, and over. I'd also like to know (If that's not the problem) What the error is to my script.

Here it is. On line 8 starts the functions:

Maps = {"Wobbly Bridge","Tower Of Magic"}
Time_Per_Round = 60
HowLongMessageLasts = 5
HowLongVotingPeriodLasts = 15
MessageToBeStated = "Seconds Left: "
Option = 1
COLOR = 1
function Op1() -- This is where the functions should be combined.
    m = Instance.new("Message", Workspace)
    m.Text = "Map Selected: ".. MAP .."!"
    wait(3)
    m:Destroy()
end
function Op2()
    m = Instance.new("Message", Workspace)
    m.Text = "".. MAP .."____ was picked!"
    wait(3)
    m:Destroy()
end
function Op3()
    m = Instance.new("Message", Workspace)
    m.Text = "You will be playing on the ".. MAP .." map"
    wait(3)
    m:Destroy()
end
function Op4()
    m = Instance.new("Message", Workspace)
    m.Text = ""
    wait(3)
    m:Destroy()
end
Players = game.Players:GetPlayers()
Ls = game.Lighting:GetChildren()
_G.MAPA = {"Wobbly Bridge"}
_G.MAPB = {"Tower Of Magic"}
_G.MAPC = {}
_G.MAPD = {}
_G.MAPE = {}
_G.MAPF = {}
_G.MAPG = {} 
_G.MAPH = {}
_G.MAPI = {}
_G.MAPJ = {}
_G.MAPK = {}
_G.MAPL = {}
_G.MAPM = {}
_G.MAPN = {}
_G.MAPO = {}
_G.MAPP = {}
_G.MAPQ = {}
_G.MAPR = {}
_G.NothingCurrently = {}
Lasting = HowLongVotingPeriodLasts
while true do
    HowLongVotingPeriodLasts = Lasting
    if #Players > 1 then
        for o = 1,#Players do
            gui = game.Lighting.Vote:Clone()
            gui.Parent = Players[o].PlayerGui
        end
        repeat
            a = HowLongVotingPeriodLasts
            wait(1)
            m = Instance.new("Message", Workspace)
            m.Text = "Voting Time: "
            a = a - 1
            wait(1)         
        until a == 0
        m:Destroy()
        for i = 1,#Players do
            val = Players[i].Map.Value
            table.insert(_G[val], val)
        end
            mapn = math.max(#_G.MAPA, #_G.MAPB, #_G.MAPC, #_G.MAPD, #_G.MAPE, #_G.MAPF, #_G.MAPG, #_G.MAPH, #_G.MAPI, #_G.MAPJ, #_G.MAPK, #_G.MAPL, #_G.MAPM, #_G.MAPN, #_G.MAPO, #_G.MAPP, #_G.MAPQ, #_G.MAPR)
            if #_G.MAPA == mapn then
                for u = 1,#Ls do
                    if Ls[u]:FindFirstChild("A") ~= nil then
                        Pick = Ls[u]
                    end
                end
            end
        Mapp = Pick:Clone()
        Mapp.Parent = Workspace
        MAP = Mapp.Name
        if Option == 1 then
            Op1()
        elseif Option == 2 then
            Op2()
        elseif Option == 3 then
            Op3()
        elseif Option == 4 then
            Op4()
        else
            print("Invalid option")
        end
        for y = 1,#Players do
            if COLOR == 1 then
                Players[y].TeamColor = BrickColor.new("Really red")
                COLOR = 2
            elseif COLOR == 2 then
                Players[y].TeamColor = BrickColor.new("Really blue")
                COLOR = 1
            end
        end
    end
end

Closed as Not Constructive by evaera

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?