KillStreak Leaderboard

What do you want to achieve?
I want to make leaderboard which counting player kills.
Here is my script:

local Players = game:GetService("Players")
local enemy = workspace.Dummy

Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	local kills = Instance.new("IntValue")
	kills.Name = "KillStreak"
	kills.Value = 0
	kills.Parent = leaderstats
	enemy.Humanoid.Died:Connect(function()
		kills.Value += 1
	end)
end)

This script is counting when I kill one npc when I need script working on several npcs. So i have multiple npcs and kill value add 1 for every kill npc.
list

1 Like

Well, I would put all enemy instances into a folder, and use a loop. For example:

local enemy_folder = -- // Path to your folder, presumably in the workspace

for _,enemy in pairs (enemy_folder:GetChildren()) do
	enemy.Humanoid.Died:Connect(function()
		kills.Value += 1
	end)
end

I don’t know if it would work like this if you were to fill out the path to the enemy folder and insert the example script into the PlayerAdded function. If not, you have a good base script you could work with.

3 Likes

Thank you so much for helping me this script is working.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.