Server Script:
local char = script.Parent local hum = char:WaitForChild("Humanoid") local plr = game.Players:GetPlayerFromCharacter(char) local plrstats = plr:WaitForChild("leaderstats") local plrcurrentkills = plrstats:WaitForChild("Current Kills") hum.Died:Connect(function() plrcurrentkills.Value = 0 for i,v in pairs(char:GetChildren()) do if v:IsA("IntValue") then local newplr = game.Players:FindFirstChild(v.Name) --clearly defines what "newplr" is local newplrstats = newplr:FindFirstChild("leaderstats") --error occurs here saying that newplr is nil local newplrcurrentkills = newplrstats:FindFirstChild("Current Kills") local newplrkills = newplrstats:FindFirstChild("Kills") newplrkills.Value = newplrkills.Value + 1 newplrcurrentkills.Value = newplrcurrentkills.Value + 1 end end end)
The script is placed in the StarterCharacterScripts
. I already set up an IntValue to be checked to reward the killer. An error happens stating that "newplr" is nil when my script clearly says what that variable is. Is this an error relating to the limits of a Server Script accessing a player's leaderboard values? I tested this in a local script and I got the same results.
It's occurring on lines 10 and 11, what does a player have to do with an Int Value?
What is "v.Name"?
What children of the character on line 9 have to do with the player's name?