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)
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