local work = game:GetService("Workspace")
local players = game:GetService("Players")
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 deaths = Instance.new("IntValue")
deaths.Name = "Deaths"
deaths.Parent = leaderstats
local totalkills = Instance.new("IntValue")
totalkills.Name = "Total kills"
totalkills.Parent = leaderstats
local streak = Instance.new("IntValue")
streak.Name = "Streak"
streak.Parent = leaderstats
player.CharacterAdded:Connect(function(char)
task.wait()
local Humanoid = char:FindFirstChild("Humanoid")
local root = char:WaitForChild("HumanoidRootPart", 10)
local pos = Vector3.new(math.random(0,253), 30, math.random(0,253))
char:MoveTo(pos)
print("Spawned "..char.Name.." at "..tostring(pos))
if not Humanoid:FindFirstChild("Killer") then
local new_tag = Instance.new("ObjectValue")
new_tag.Name = "Killer"
new_tag.Parent = Humanoid
end
Humanoid.Died:Connect(function(died)
deaths.Value += 1
streak.Value = 0
local tag = Humanoid:FindFirstChild("Killer")
local killer = tag.Value
if tag and killer and killer ~= nil and killer ~= player then
killer.leaderstats:FindFirstChild("Kills").Value += 1
killer.leaderstats:FindFirstChild("Streak").Value += 1
end
end)
end)
end)
I have an error in last line, it says leaderstats is not a part of player.
local tag = Humanoid:FindFirstChild("Killer")
local killer = tag.Value
if tag and killer and killer ~= nil and killer ~= player then
killer.leaderstats:FindFirstChild("Kills").Value += 1
killer.leaderstats:FindFirstChild("Streak").Value += 1
end