Hello guys, I just wrote a leaderstats code and it enters IntValue into player but it isn't showing up on leaderstats. It also won't show any error...anyone can help me?
game.Players.PlayerAdded:connect(function(player) local stats = Instance.new('IntValue', player) stats.Name = 'LeaderStats' local cash=Instance.new('IntValue',stats) cash.Name = 'Cash' cash.Value = 0 local rank=Instance.new('StringValue', stats) rank.Name='Rank' rank.Value='Private' end)
The 'leaderstats' object is case sensitive and should be named with all lowercase letters. It is also advised for the object to be a folder or model as there is a chance it won't work if you use a Value object.
game.Players.PlayerAdded:connect(function(player) local stats = Instance.new("Folder") stats.Name = "leaderstats" stats.Parent = player local cash = Instance.new("IntValue") cash.Name = "Cash" cash.Value = 0 cash.Parent = stats -- which ever other stats you want end)
The object must be named leaderstats
with only lowercase letters.
I added the line to get the user's role from a groupid you need to enter.
game.Players.PlayerAdded:connect(function(player) Instance.new("Folder", player).Name = "leaderstats" Instance.new("NumberValue", player).Name = "Cash" Instance.new("StringValue", player).Name = "Rank" player.leaderstats.Rank.Value = player:GetRoleInGroup(0) end)