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

How do I make it so you get all players in a clickdetector script?

So I wanna make it so you can get all players in a click detector script instead of just the one who clicked. The code below:

script.Parent.MouseClick:Connect(function(plr)

Only gets the player who clicked. Is it possible to fix this? The reason is because im using table.Insert to make a player who survived gui, and it unpacks the table after, so I wanna get all players instead of the one who clicked.

10 comments

0

Hi I dont fully understand your question what are you trying to do are you trying to get all the players who clicked the gui or that are in the server

0

all players in the server

0

O you do not need a click detector for that

0

well im making a dont press the button game and im checking all players if a bool value i put in them is true and if its true it means they died and itll put them in a table

0

but it only gets the player who clicked when i do

0

You can get an array of all players using game.Players:GetPlayers(). This will return a table of all the players in the game. From there, you can use a for loop to check if the bool is ticked true or false.

0

You can get an array of all players using game.Players:GetPlayers(). This will return a table of all the players in the game. From there, you can use a for loop to check if the bool is ticked true or false.

0

You can get an array of all players using game.Players:GetPlayers(). This will return a table of all the players in the game. From there, you can use a for loop to check if the bool is ticked true or false.

0

You can get an array of all players using game.Players:GetPlayers(). This will return a table of all the players in the game. From there, you can use a for loop to check if the bool is ticked true or false.

0

You may want to reword your question to ask how to detect players who did not press the button since a click detector will only help you detect who pressed it you have to do further work if you want to see who did not press

1 answer

✓ Accepted answer

Based on what you said in the comments I beleive what you want to do is get all the players in the server to do this you may want to do

PlayersService = game:GetService("Players")
Players = PlayersService:GetPlayers()
--Though this would store the player object of every player in a table instead you may want to print all the names of the players like this

for i, player in pairs(Players) do
    print(player.Name)
end

--or to add the names to a table
playertable = {}
for i, player in pairs(Players:GetPlayers()) do
    table.insert(playertable, player.Name)

end


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