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

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

Asked by 4 years ago
Edited 4 years ago

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.

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 Natsudragneel2500 80 — 4y
0
all players in the server gringlestick2 -178 — 4y
0
O you do not need a click detector for that Natsudragneel2500 80 — 4y
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 gringlestick2 -178 — 4y
View all comments (6 more)
0
but it only gets the player who clicked when i do gringlestick2 -178 — 4y
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. CreationNation1 459 — 4y
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. CreationNation1 459 — 4y
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. CreationNation1 459 — 4y
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. CreationNation1 459 — 4y
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 Natsudragneel2500 80 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

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


Ad

Answer this question