Here is the whole script:
lp = game.Players.LocalPlayer
function onPlayerEntered(newPlayer)
local stats = Instance.new("IntValue")
stats.Name = "leaderstats"
local HighScore = Instance.new("IntValue")
HighScore.Name = "HighScore"
HighScore.Value = 0
local Score = Instance.new("IntValue")
Score.Name = "Points"
Score.Value = 0
HighScore.Parent = stats
Score.Parent = stats
stats.Parent = newPlayer
end
game.Players.ChildAdded:connect(onPlayerEntered)
script.ChildAdded:connect(function (Obj)
print("Leaderboard script has a child added.")
if Obj:IsA "IntValue" and rawequal(Obj.Name, "HighScore") then
if lp then
local ls = lp:findFirstChild("leaderstats")
hs = ls:findFirstChild("HighScore")
hs.Value = Obj.Value
Obj:destroy()
end
elseif Obj:IsA "IntValue" and rawequal(Obj.Name, "Score") then
if lp then
local ls = lp:findFirstChild("leaderstats")
sc = ls:FindFirstChild("Points")
sc.Value = sc.Value + Obj.Value
Obj:destroy()
end
end
end)
It runs, adds the leaderboard. However, when an object is added it does not fire and print "Leaderboard script has a child added."
What is wrong?

1 comment
This did not fix the error. Nothing is being printed (still).