Kill count system using different tools

  1. Is it possible to create a kill count system using different tools with different damage and hitbox systems?

My Leaderstats:
local DataStoreService = game:GetService(“DataStoreService”)
local killsDataStore = DataStoreService:GetDataStore(“PlayerKills”)

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

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

local success, savedKills = pcall(function()
	return killsDataStore:GetAsync(player.UserId)
end)

if success then
	kills.Value = savedKills or 0 
else
	warn("Não foi possível carregar os dados para " .. player.Name)
end

player.AncestryChanged:Connect(function()
	if not player:IsDescendantOf(game) then
		pcall(function()
			killsDataStore:SetAsync(player.UserId, kills.Value)
		end)
	end
end)

end)

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character:FindFirstChild(“Humanoid”)
if humanoid then
humanoid.Died:Connect(function()
local killer = humanoid:FindFirstChild(“creator”) – Localiza o killer (criador do dano)
if killer and killer.Value and killer.Value:IsA(“Player”) then
local killerPlayer = killer.Value
if killerPlayer and killerPlayer:FindFirstChild(“leaderstats”) then
local kills = killerPlayer.leaderstats:FindFirstChild(“Kills”)
if kills then
kills.Value += 1
end
end
end
end)
end
end)
end)

Yes. You just have to add the tag everytime you give damage to someone with a tool.
This could look like this:

local Humanoid =  --Add the humanoid of the player that you attack here
if Humanoid:FindFirstChild("Creator") then --Check if it already exists
	Humanoid.Creator.Value = player --Set the value to the player 
else --If it doesn't exist, create a value
	local Creator = Instance.new("ObjectValue")
	Creator.Name = "Creator"
	Creator.Value = player --Set the value to the player 
	Creator.Parent = Humanoid
end
Humanoid:TakeDamage(100) --Take Damage
1 Like

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