How to change everyone's leaderstats in a server

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    After the boss dies, everyone in the server will get gold (the currency on the leaderstat).

  2. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried to do game.players.localplayer but that didn’t work, or the way i executed didnt work
    then i tried to get everyone’s username like local plyr = game:GetService(“Players”):GetPlayers()
    but it didnt work.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- This is an example Lua code block

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Use a for loop through the players…

for i,v in pairs(game.Players:GetPlayers()) do
    local leaderstat
    local success, result = pcall(function()
        leaderstat = v:FindFirstChild("leaderstats")
    if success then
        local gold = leaderstat:FindFirstChild("Gold")
        gold.Value += 1
1 Like