i just tried that and it didnt work
wait i just thought of a solution
the problem is probably because Player.CharacterAdded
wont trigger in the event Players.PlayerAdded
for some reason. to fix this, just move your Player.CharacterAdded
function in a normal script under StarterCharacterScripts so that the script runs whenever the player spawns and respawns
no that doesnt fix anything
dont mind this
In general, it’s a strange situation because the regular script with the humanoid does work. You can try reverting everything back and use this script
Player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:WaitForChild("Humanoid")
if Humanoid then
Humanoid.Died:Connect(function(Hum)
for i, Child in pairs(Humanoid:GetChildren()) do
if Child:IsA('ObjectValue') and Child.Value ~= nil then
print("Obj")
print(Child.Value)
local Killer = Child.Value
if Killer:IsA("Player") then
print("PLAYER")
local Kill = Killer.leaderstats.Kills
local Times = Killer.leaderstats.Time
Times.Value = Times.Value + Player.leaderstats.Time.Value
Kill.Value += 1
end
end
end
end)
end
end)
i didnt mean moving the entire script under StarterCharacterScripts, only move the respawn part of the script. like this
local Players = game:GetService("Players")
local Character = script.Parent
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
local Player = Players:GetPlayerFromCharacter(Character)
local leaderstats = Player:FindFirstChild("leaderstats")
Humanoid.Died:Connect(function()
local Tag = Humanoid:FindFirstChild("creator")
if Tag and Tag:IsA("ObjectValue") and Tag.Value and Tag.Value:IsA("Player") then
local Killer = Tag.Value
local killerLeaderstats = Killer:FindFirstChild("leaderstats")
local Kills = killerLeaderstats:FindFirstChild("Kills")
local Time = killerLeaderstats:FindFirstChild("Time")
Time.Value += leaderstats:FindFirstChild("Time").Value
Kills.Value += 1
end
end)
if you put this code in StarterCharacterScripts it should run whenever the player spawns and respawns
it should be a local script right?, nvm i believe it should be server
should be server definitely definitely