Adding the players time to their killers time

idk, thats what people told me to do. and if you are asking about the sword, this is the classic sword from the roblox toolbox

2 Likes

image
i think its likned to the player? or humanoid

2 Likes

ObjectValue can be used immediately to store any Instance.

2 Likes

Yes, it’s creating an ObjectValue in the humanoid, and it needs to be checked whether it’s being created in the humanoid in hit

1 Like

Why are you deleting it after 2 seconds?

1 Like

I could write you a script, but that will have to be later.

1 Like

like i said, i didnt maake the sword. it was from the toolbox

1 Like

image

the one by roblox

1 Like

Just check if the ObjectValue is being added to the Humanoid after the hit.
Or you can share the saves so that we can check it ourselves.

2 Likes

it is being added after is hit


creator is the object value

2 Likes

Please show what is inside the ‘value’.

2 Likes

you mean like this?

Try this, let me know the result

plr.CharacterAdded:Connect(function(Character)
		local Humanoid = Character:WaitForChild("Humanoid")
		if Humanoid then
			Humanoid.Died:connect(function()
				for i, Child in pairs(Humanoid:GetChildren()) do
					if Child:IsA('ObjectValue') and Child.Value ~= nil then
						local Killer = Child.Value
						if Killer:IsA("Player") then
							local Kill = Killer.leaderstats.Kills
							local Times = Killer.leaderstats.Time
							Times.Value = Times.Value + plr.leaderstats.Time.Value
							Kill.Value += 1
						end
					end
				end
			end)
		end
	end)
1 Like

Since you only want it to add time when the other player is dead before the damage is dealt check if the player the other player is attacking has less health than the damage the sword does and if so take the player name from the raycast (assuming the sword uses raycast), make a value in them and set it to the name of the player who killed the other player.

No that doesn twork, and the kills arent being added in this script

Try this, show the result

plr.CharacterAdded:Connect(function(Character)
		local Humanoid = Character:WaitForChild("Humanoid")
		if Humanoid then
			Humanoid.Died:Connect(function(Hum)
				print("Check")
				print(Hum)
				print(Humanoid:FindFirstChild("creator"))
				for i, Child in pairs(Humanoid:GetChildren()) do
					if Child:IsA('ObjectValue') and Child.Value ~= nil then
						local Killer = Child.Value
						if Killer:IsA("Player") then
							local Kill = Killer.leaderstats.Kills
							local Times = Killer.leaderstats.Time
							Times.Value = Times.Value + plr.leaderstats.Time.Value
							Kill.Value += 1
						end
					end
				end
			end)
		end
	end)

Instead of iterating the children of Humanoid, why not just get an instance named “creator” instead.

	plr.CharacterAdded:Connect(function(Character)
		local Humanoid = Character:FindFirstChildOfClass("Humanoid")
		if Humanoid then
			Humanoid.Died:Connect(function()
				local Tag = Humanoid:WaitForChild("creator", 5)
				if Tag then
					local Killer = Tag.Value
					if Killer:FindFirstChild("leaderstats") and Killer.leaderstats:FindFirstChild("Kills") then
						local Kill = Killer.leaderstats.Kills
						local Times = Killer.leaderstats.Time
						Times.Value += plr.leaderstats.Time.Value
						Kill.Value += 1
					end
				end
			end)
		end
	end)
end)

Killer:IsA(“Player”) doesn’t work as Killer is just a name and has no class.

it doesnt work, kills are being aadded though

if you guys want i can show you the full script?