How do i put my coins stats into the same leader stats folder as kills leader stats?

I have been trying to make a leader stats folder where 2 of my leader stats can go into, I have only managed to make 2 leader stats folders instead of putting one of the leader stats into the same folder.

here are the 2 scripts-

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

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)

I am very new to scripting, so if someone could tell me the enitre script, that would be great. so i just need the coins to go in the kills leader stats folder.

thank you for everyone that reply’s :smiley:

I have a question, why can’t you just put the Kills & Coins leaderstats in the same folder…? It’ll make it easier for you & be able to practice more with it, I don’t think it’ll be able to replicate the leaderstat if you put the Coins in the Kills leaderstats

ya that’s what I’m trying to ask, is how do i put the kills and coins leader stats in the same folder.

i am very new to scripting and I do not know how to do that yet.

Ah it’s fine! Well it’s actually pretty simple, and I’ll give you an example

So what we’d wanna do first is go ahead and create our Function, preferably whenever a player joins so:

game.Players.PlayerAdded:Connect(function(player)
end

This event is pretty straightforward, as they fire whenever a player joins a game

Now next we can go ahead and create our variables (Or our leaderstats)

game.Players.PlayerAdded:Connect(function(player)
    local Leaderstats = Instance.new("Folder", player)
    Leaderstats.Name = "leaderstats"
    
    local Kills = Instance.new("IntValue", Leaderstats)
    Kills.Name = "Kills"
    Kills.Value = 0

    local Coins = Instance.new("IntValue", Leaderstats)
    Coins.Name = "Coins"
    Coins.Value = 0
end

So what we’re doing here, is creating individual leaderstats for each player whenever they join! And we’re also parenting our IntValues into the leaderstats Folder so that they’ll work right!

ok, ill go test it out! Thank you, and ill tell you if it works.

Another thing, make sure to put it either in the Workspace or ServerScriptService cause it needs to be done Server-Sided (Or shown on the server & not on the client)

yes , that is very true. Thanks.

This sadly does not seem to work, it is not making a coin stat. can you please tell me how to make a coin stat that goes into the leader stat’s folder?

That’s what I’m having trouble with, the kills work just fine.

Oh my apologies! Forgot to include a end) :sweat_smile:
Try this instead?

game.Players.PlayerAdded:Connect(function(player)
    local Leaderstats = Instance.new("Folder", player)
    Leaderstats.Name = "leaderstats"
    
    local Kills = Instance.new("IntValue", Leaderstats)
    Kills.Name = "Kills"
    Kills.Value = 0

    local Coins = Instance.new("IntValue", Leaderstats)
    Coins.Name = "Coins"
    Coins.Value = 0
end)

Also make sure that no other leaderstats scripts are being inserted as well

im just tring to get the coins leaderstats. so do i delete all of this____

game.Players.PlayerAdded:Connect(function(player)
local Leaderstats = Instance.new(“Folder”, player)
Leaderstats.Name = “leaderstats”

local Kills = Instance.new("IntValue", Leaderstats)
Kills.Name = "Kills"
Kills.Value = 0

or do i keep the game.Players.PlayerAdded:Connect(function(player) ???

so in totall the script is
game.Players.PlayerAdded:Connect(function(player)

local Coins = Instance.new(“IntValue”, Leaderstats)
Coins.Name = “Coins”
Coins.Value = 0
end) ???

Well, if you just want the Coins leaderstats yeah just remove the Kills variable and the other lines that have “Kills” as well

leaderstats is a folder inside of a player… 1 folder… not multiple…

just put them both in the same function

still not working sadly, i believe we are very close to finding the problem. i think its because i do not need a new “leaderstats” folder, i already have one inside the kills script. maybe you should try testing it out in studio???

and make sure that coins and kills still work?