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

Why is my voting script not working?

Asked by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

I get no errors or anything. Please help.

It's funny, when I take out the Changed event and just test it by disabling/enabling the script, everything works fine.

local h = Instance.new("Hint")

function countdown(cTime)
    h.Parent = workspace
    for i = 1,cTime do
        h.Text = tonumber(cTime - i)
    end
end

function votingVisible(bool)
    for i,v in pairs(game.Players:GetPlayers()) do
        v.PlayerGui.ScreenGui.Voting.Visible = bool
    end
end

game.Players.Changed:connect(function()
    if game.Players.NumPlayers == 1 then
        h.Parent = workspace
        h.Text = "Waiting for 2 players."
        votingVisible(false)
    elseif game.Players.NumPlayers == 2 then
        votingVisible(true)
        countdown(10)
        votingVisible(false)
    end
end)

1 answer

Log in to vote
1
Answered by 10 years ago

You should add a variable at:

game.Players.Changed:connect(function()

Like:

game.Players.Changed:connect(function(a)

Normally errors appear at Developer Console

To see it, press F9.

Also... Shouldn`t you think after 2 players on the game?

0
"Shouldn't you think after 2 players on the game" What do you mean by this? Perci1 4988 — 10y
0
I got it to work, no thanks to anyone on this website, but I appreciate you trying. Perci1 4988 — 10y
Ad

Answer this question