Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is this not working?

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

✓ Accepted answer

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

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.

1 comment

0

Can you show me how?

This discussion is preserved as it was. New answers, comments, and votes are closed.