Leaderstat Issue

  1. What I am trying to achieve right now is a four stat leader board that contains the following stats: Credits, Time, Kills, and Deaths.

  2. The issue that I am having is that only two leaderstats appear when I am trying to have four, and plus whenever the player dies to NPC’s it doesn’t add a death.

  3. I have tried combining scripts I even have two separate scripts however it only shows two instead of four.

(Keep in mind I am no scripter!)

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

local money = Instance.new("IntValue", leaderstats)
money.Name = "Credits"
money.Value = 0

local time = Instance.new("IntValue", leaderstats)
time.Name = "Time"
time.Value = 0
while true do
	wait(60)
	time.Value = time.Value + 1
end

end)

game.Players.PlayerAdded:Connect(function(plr)

local stats = Instance.new("Folder")
stats.Name = "leaderstats"
stats.Parent = plr

local kills = Instance.new("IntValue")
kills.Name = "Kills"
kills.Parent = stats

local deaths = Instance.new("IntValue")
deaths.Name = "Deaths"
deaths.Parent = stats

plr.CharacterAdded:connect(function(char)
	local humanoid
	repeat
		humanoid = char:FindFirstChild("Humanoid")
		wait()
	until humanoid
	humanoid.Died:connect(function() 
		deaths.Value = deaths.Value + 1 
		local tag = humanoid:FindFirstChild("creator") 
		if tag then  
			local killer = tag.Value  
			if killer then   
				killer.leaderstats.Kills.Value = killer.leaderstats.Kills.Value + 1
			end   
		end 
	end)     
end)

end)

1 Like

You are creating 2 leaderstat folders, so instead of doing that you just wanna put all values into 1 folder like this:

game.Players.PlayerAdded:Connect(function(plr)

	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = plr

	local kills = Instance.new("IntValue", leaderstats)
	kills.Name = "Kills"

	local deaths = Instance.new("IntValue", leaderstats)
	deaths.Name = "Deaths"
	
	local money = Instance.new("IntValue", leaderstats)
	money.Name = "Credits"
	money.Value = 0

	local Time = Instance.new("IntValue", leaderstats)
	Time.Name = "Time"
	Time.Value = 0

	while true do
		wait(60)
		Time.Value = Time.Value + 1
	end
end)