How to increase 2 IntValues from leaderboard at once?
Asked by
5 years ago Edited 5 years ago
heres what i want:
01 | local Players = game.Players |
03 | local Template = Instance.new 'BoolValue' |
04 | Template.Name = 'leaderstats' |
06 | Instance.new( 'IntValue' , Template).Name = "Kills" |
07 | Instance.new( 'IntValue' , Template).Name = "Deaths" |
08 | Instance.new( 'IntValue' , Template).Name = "Bux" |
11 | Players.PlayerAdded:Connect( function (Player) |
13 | local Stats = Template:Clone() |
15 | local Deaths = Stats.Deaths |
16 | Player.CharacterAdded:connect( function (Character) |
17 | Deaths.Value = Deaths.Value + 1 |
18 | local Humanoid = Character:FindFirstChild "Humanoid" |
20 | Humanoid.Died:Connect( function () |
21 | for i, Child in pairs (Humanoid:GetChildren()) do |
22 | if Child:IsA( 'ObjectValue' ) and Child.Value and Child.Value:IsA( 'Player' ) then |
23 | local Killer = Child.Value |
24 | if Killer:FindFirstChild 'leaderstats' and Killer.leaderstats:FindFirstChild "Kills" then |
25 | local Kills = Killer.leaderstats.Kills |
26 | local Bux = Killer.leaderstats.Bux |
27 | Kills.Value = Kills.Value + 1 |
28 | Bux.Value = Bux.Value + math.Random( 15 , 25 ) |
what i try to do is increase 2 int values from the leaderboard when a kill is made but is there another instance than findfirstshild so that i can increase both instead of 1?