I have a sort of sword fighting game and I want to make it where A kills B, A’s time is increased by how much time B has. I have tried to make this myself but I can’t.
plr.CharacterAdded:connect(function(Character)
local Humanoid = Character:FindFirstChild("Humanoid")
if Humanoid then
Humanoid.Died:connect(function()
for i, Child in pairs(Humanoid:GetChildren()) do
if Child:IsA('ObjectValue') and Child.Value and Child.Value:IsA('Player') then
local Killer = Child.Value
if Killer:FindFirstChild 'leaderstats' and Killer.leaderstats:FindFirstChild "Kills" then
local Kill = Killer.leaderstats.Kills
local Times = Killer.leaderstats.Time
Times.Value = Times.Value + plr.leaderstats.Time.Value
Kill.Value = Kill.Value + 1
end
return
end
end
end)
end
end)
end)
The only problem is adding the time and nothing else. There isn’t any errors
Can you post how you set up your explorer? (Also why the humanoid.Died function in a player.CharacterAdded function, they basically do the same thing except player.CharacterAdded fires when someone join the game and when their character dies. In your script you also put if Child:IsA(‘ObjectValue’) and Child.value:IsA(‘Player’). To me this doesn’t make sense so your checking if the child is an object value and then checking if it’s value is a player? Correct me if I’m wrong.
Ok let’s start from the beginning. We create two values one being a string to store the player who killed the other player (every death this resets) and the other value being the leader stat value. Then we get both the players leaderstat value and depending on who got the kill we add the dead player time to the one who got killed