Detecting all players who clicked a part

So I have a button in my game that has a NumberValue of 1000 and every time it’s clicked it goes down by one.


When the last click is reached and the NumberValue reaches <= 1 then it resets and gives a leaderstats value to the person who got the last click, but I want to be able to save the names of every player who contributed to at least 1 click of the 1000 and give all of them the stat but I’m not sure if there’s a function or how to store those names.

1 Like

Make a table and store player names inside the table. When the last click happens, give the last player the reward instead of adding them to the table, and then loop through the table, do whatever you need, and clear the table. Read more here: Tables | Documentation - Roblox Creator Hub

--//Add this at the top of your script
local players = {}

--//Add this when a player clicks a button
table.insert(players, plr.Name)

--//Add this when the clicks left is 0
for _,p in pairs(players) do
      --//reward code here
end 
players = {}

Completely forgot tables are a thing outside of modules, thanks lol.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.