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

Why is this not working?

Asked by 9 years ago

Can anyone fix this code?It is not working?

minigames=game.Lighting.Maps:GetChildren()

local g=game.StarterGui.ScreenGui.TextBox

local players = game:GetService("Players")

local numPlayers = players.NumPlayers

wait(3)
while true do
    wait(3)
    if numPlayers>4 then
        wait(3)
        g.Visible=true
        g.Text='Chosing Map'
        ranGame=math.random(1,#minigames)
        gamechosen=minigames[ranGame]
        g.Text='The Round For This Round Will be'..gamechosen.Name
        wait(3)
        gamechosenclone=gamechosen:Clone()
        gamechosenclone.Parent=game.Workspace
        for i=10,1,-1 do
            wait(3)
            g.Text='Time Left'..i
        end
        g.Text='Game Ended'
        wait(3)
        gamechosenclone:Destroy()
    else
        g.Visible=true
        g.Text='There Needs To Be At Least 4 Players To Start'
    end
end


2 answers

Log in to vote
0
Answered by 9 years ago

You need to define NumPlayers inside the while script, not outside it, because NumPlayers defaults at 0. Variables do not auto-update themselves.

Ad
Log in to vote
2
Answered by
Tigerism 220 Moderation Voter
9 years ago

The problem is NumPlayers, like the previous answer says.

However, your text won't display because

local g=game.StarterGui.ScreenGui.TextBox

That won't replace everyone's textbox text. You need to change for each player; I recommend using RemoteEvents to FireAllClients() the change.

0
Can you show me how? Accelital -7 — 9y

Answer this question