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

This script spams a message constantly, what's wrong with it? [UNANSWERED]

Asked by 10 years ago

So there's a problem with this script. It spams "Voting Time:", over, and over again. Just constantly. It does it even if there isn't 2 players in the game. Does anyone know the error? Here's the script.

Maps = {"Wobbly Bridge","Tower Of Magic"}

Time_Per_Round = 60

HowLongMessageLasts = 5

HowLongVotingPeriodLasts = 15

MessageToBeStated = "Seconds Left: "

Option = 1

COLOR = 1

function Op1()

    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.NothingCurrently = {}

Lasting = HowLongVotingPeriodLasts

while true do
wait()
    HowLongVotingPeriodLasts = Lasting

    if game.Players.NumPlayers >= 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)

            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

3 answers

Log in to vote
0
Answered by 10 years ago

Replace:

repeat

            a = HowLongVotingPeriodLasts

            wait(1)

            m = Instance.new("Message", Workspace)

            m.Text = "Voting Time: "

            a = a - 1

            wait(1)

until a == 0

with:

local m = Instance.new("Message", game.Workspace)

m.Text = "Voting Time: "

wait(HowLongVotingPeriodLasts)

m:Destroy()

This should work

Ad
Log in to vote
0
Answered by
mymw 5
10 years ago

local ChrNum = {"39563808","80254","1","48705637","15861410","42943434"} local Randomizer = ChrNum[math.random(1,#ChrNum)] game.Players.PlayerAdded:connect(function(plr) local use = true plr.CharacterAdded:connect(function(chr) if use == true then use = false plr.CharacterAppearance = "http://www.roblox.com/Asset/CharacterFetch.ashx?userId="..Randomizer.."&placeId="..game.PlaceId wait() plr:LoadCharacter() end end) end)
0
Oops. I put in the wrong script. I don't know a script to replace it with. mymw 5 — 10y
0
Remove this, this has nothing to do with the original question. Nickoakz 231 — 10y
Log in to vote
0
Answered by
Nickoakz 231 Moderation Voter
10 years ago

Its flooding one message for a reason.. Look harder.

Maps = {"Wobbly Bridge","Tower Of Magic"}
Time_Per_Round = 60
HowLongMessageLasts = 5
HowLongVotingPeriodLasts = 15
MessageToBeStated = "Seconds Left: "
Option = 1
COLOR = 1
function Op1()
    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.NothingCurrently = {}
Lasting = HowLongVotingPeriodLasts
while true do
wait()
    HowLongVotingPeriodLasts = Lasting
    if game.Players.NumPlayers >= 1 then
        for o = 1,#Players do
            gui = game.Lighting.Vote:Clone()
            gui.Parent = Players[o].PlayerGui
        end
        a = HowLongVotingPeriodLasts --You are consistantly setting
        -- a to the default and repeating it, thats the problem
        wait(1) --Get this OUT OF THE REPEAT
        repeat
            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)
            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

Answer this question