I put script in ServerScriptStorage
value = script.Killed
-- my attempt
while wait(1) do
for _,v in ipairs(workspace:GetChildren()) do
if v:FindFirstChild("Humanoid") and not v:FindFirstChild("tracked") then
spawn(function()
repeat wait() until v.Humanoid.Health <= 0
value.Value = value.Value + 1
t = Instance.new("StringValue")
t.Parent = v
t.Name = 'tracked'
end
end
end
end
that is my best attempt from scratch(no testing involved) i would like to know if there are better ways to do this as will use many resources in the game you know? thanks you for the time.
000 EDIT - Additionally this is how i would track who the killer of humanoid was : 000
while wait(1) do
for _,v in ipairs(workspace:GetChildren()) do
if v:FindFirstChild("Humanoid") and not v:FindFirstChild("tracked") then
spawn(function()
repeat wait() until v.Humanoid.Health <= 0
value.Value = value.Value + 1
t = Instance.new("StringValue")
t.Parent = v
t.Name = 'tracked'
if v.Humanoid:findFirstChild("creator") and v.Humanoid.creator.Value ~= nil and not script:FindFirstChild(v.Humanoid.creator.Value.Name) then
player = Instance.new("IntValue", script)
player.Value = player.Value = 1
player.Name = v.Humanoid.creator.Value.Name
elseif v.Humanoid:FindFirstChild("creator") and v.Humanoid.creator.Value ~= nil and script:FindFirstChild(v.Humanoid.creator.Value.Name) then
player = script:WaitForChild("v.Humanoid.creator.Value.Name)
player.Value = player.Value + 1
end
end
end
end
end
