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

how to set all leaderboard stats to 0?

Asked by 2 years ago

Im trying to make a round game similar to item asylum and after each round i want to reset the leaderboard stats of every player.

3 answers

Log in to vote
0
Answered by 2 years ago

You could do something like -

Local players = game: GetService("Players")

Local playersArray = players:GetChildren ()

For I, plrs in pairs(playersArray) do

    plrs.leaderstats.Money.Value = 0 

End




Ad
Log in to vote
0
Answered by
MattVSNNL 620 Moderation Voter
2 years ago

Hello, I don't mean to be a pest but, ScriptingHelpers.org is not a website to get scripts, It's a place to ask developers why your script isn't working, but enough of that, here's a script

We use something called a for loop, a foor loop loops through every single item in the thing you want to search, so say you have a Folder full of parts and want to count how many their are, you use a for loop to get all of the objects in the folder and add one to the count and after the loop it shows how many there was!

Script:

local PlayersService = game:GetService("Players")

local leaderstatName = "Money" -- Change to the leaderstat name of the leaderstat you wanna change

for _, player in pairs(PlayersService:GetPlayers()) do
    if player then

        player.leadersats[leaderstatName].Value = 0

    end
end
Log in to vote
0
Answered by
enes223 327 Moderation Voter
2 years ago

hey you! have you ever heard of enes? if you are in trouble, better call enes!

Answer this question