Here is the whole script:
lp = game.Players.LocalPlayer function onPlayerEntered(newPlayer) local stats = Instance.new("IntValue", newPlayer) 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 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?
Posted previously but got no working answer. https://scriptinghelpers.org/questions/440/scriptchildadded-not-firing
It is because on lines 31 and 24 you do not have ('s or )'s around :IsA().
Read more about the "IsA()" Instance here