I would like to have 2 leader stats working at once, but it will only chose one or the other.
I am trying to have a kill leader stat and a Coin leader stat working at the same time.
someone said that its because i have 2 Instances but i am new to scripting so i do not know how to script yet.
Here is the script for the kill leader stats -
local Players = game.Players
local Template = Instance.new ‘BoolValue’
Template.Name = ‘leaderstats’
Instance.new(‘IntValue’, Template).Name = “Kills”
Players.PlayerAdded:connect(function(Player)
wait(1)
local Stats = Template:Clone()
Stats.Parent = Player
Player.CharacterAdded:connect(function(Character)
local Humanoid = Character:FindFirstChild "Humanoid"
if Humanoid then
Humanoid.Died:connect(function()
for i, Child in pairs(Humanoid:GetChildren()) do
if Child:IsA('ObjectValue') and Child.Value and Child.Value:IsA('Player') then
local Killer = Child.Value
if Killer:FindFirstChild 'leaderstats' and Killer.leaderstats:FindFirstChild "Kills" then
local Kills = Killer.leaderstats.Kills
Kills.Value = Kills.Value + 1
end
return
end
end
end)
end
end)
end)
And here is the coins leader stats-
local function onPlayerJoin(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local coins = Instance.new("IntValue")
coins.Name = "Coins"
coins.Value = 0
coins.Parent = leaderstats
end
game.Players.PlayerAdded:Connect(onPlayerJoin)
Those are the scripts that i have, and most people say its because 2 Instances. But i have very little experience on how to script yet, so if someone can just say the new entire script That would be great
and i am hoping that someone could make changes to the coin script.
I Hope everyone has a great day!
.