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

How can I use MaxPlayers Value to do something a certain number of times?

Asked by
Validark 1580 Snack Break Moderation Voter
9 years ago

So what I want to do is create a bunch of textbuttons on a surfacegui, but I need the textbuttons to equal the max players.

Here is what I have thought to do

for i=1,(game.Players.MaxPlayers) do
[Generate TextButton code is functional and would go here]
end

If this matters, this is going on a brick and will display the names of everyone who joins.

1 answer

Log in to vote
2
Answered by 9 years ago

What I would do, is use the PlayerAdded and PlayerRemoving events. Here's an example:

This code will print [Player's Name] Has joined the server when a new player is added and [Player Name] Has left the server When the player leaves:

game.Players.PlayerAdded:connect(function(player) -- Calls the player
print(player.Name.." Has Joined the Game")
end)

game.Players.PlayerRemoving:connect(function(player)
print(player.Name.." Has left the game.")
end)

So by using these events, you can easily:

Clone the GUI (When the player enters) Edit the GUI (You're choice how) Remove the GUI (by using :Destroy())

Hope I helped :D Feel free to PM me if you have any more trouble with this.

Ad

Answer this question