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 add multiple leaderstats?

So I am trying to make multiple Leaderstats, but there is one problem, whenever I join the game chooses one of the leaderstats and makes the other one nil? what is the problem?

here's the script for the first leaderstat:

                               game.Players.PlayerAdded:Connect(function(plr)
                                local stats  = Instance.new("IntValue", plr)
                                stats.Name = "leaderstats"

                                local Gold = Instance.new("IntValue", stats)
                                Gold.Name = "Gold"
                                Gold.Value = 0
                    end)

Script for the 2nd leaderstat:

                      game.Players.PlayerAdded:Connect(function(plr)
              local stats  = Instance.new("IntValue", plr)
              stats.Name = "leaderstats"

             local Fishies = Instance.new("IntValue", stats)
              Fishies.Name = "FishCaught"
              Fishies.Value = 0
                end)

1 answer

✓ Accepted answer

You are creating two instances of leaderstats. You can only have one instance, then append all of your individual stats to that instance.

As a side note, don't use the Instance.new("IntValue", stats) because it can give a huge performance hit in the long run. You should do Instance.new("IntValue"), then set all properties of that instance, then parent it afterwards using stat.Parent = stats

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