Here's my script:
playerCount = {}
Players = Game:GetService("Players")
Players.PlayerAdded:connect(function(Player)
table.insert(playerCount, Player.Name)
print(table.concat(playerCount, ", "))
end)
Players.PlayerRemoving:connect(function(Player)
for index = 1, #playerCount do
if playerCount[index] == Player.Name then
table.remove(playerCount, index)
print(table.concat(playerCount, ", "))
break
end
end
end)
epic = true
while epic == true do
if #playerCount == 2 then
local hint = Instance.new("Hint", Workspace)
hint.Text = "The game will begin shortly."
epic = false
else hint = "Two people are needed to start the game."
end
end
The only thing I have a problem with is that last part.
What it's supposed to do is: until 2 players have entered, it's gonna have a hint at the top of the screen saying "Two players are needed to start the game." until 2 players have entered. Once 2 players have entered, it will show a hint saying, "The game will begin shortly."
Only, no hint is showing up whenever I do it.
Please help me with this.

4 comments
Wait, so really, I didn't need all that about adding the players into and out of playerCount, I could of just done this instead???
Yes. But believe me, this happens to everyone. I once rewrote math.atan2 - after 2 minutes I noticed it. "Hmm, what is math.atan2? Aha! The function I just wrote ._.". These are just things you have to know. Your approach was good though, that worked! The while loop was the problem here.
This actually took me hours of asking for help and trying to figure stuff out in order to get this. Thanks!
That's even better. What you did was not wrong - I'm just telling here that you could also have shortened your code. You now at least know how to use events, the "table" library and how to get table lengths. It has not be a waste!