Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

why does line 9 of this leaderboard script throw an error???

Asked by 9 years ago
game.Players.PlayerAdded:connect(function(plr) 
 local stats = Instance.new("IntValue", game.Workspace)     
 stats.Name = "leaderstats" 
 local points = Instance.new("IntValue", stats)
 points.Name = "Points"
 points.Value = 0
 plr.CharacterAdded:connect(function(char)
    (char:WaitForChild("Humanoid")).Died:connect(function()
        plr.leaderstats.points.Value = plr.leaderstats.points.Value - 1
    end)
end)
end)

why does line 9 of this leaderboard script throw an error once humanoid dies???

2 answers

Log in to vote
0
Answered by 9 years ago
game.Players.PlayerAdded:connect(function(plr) 
    local stats = Instance.new("IntValue", plr)     
    stats.Name = "leaderstats" 
    local points = Instance.new("IntValue", stats)
    points.Name = "Points"
    points.Value = 0
    plr.CharacterAdded:connect(function(char)
        (char:WaitForChild("Humanoid")).Died:connect(function()
            points.Value = points.Value - 1
        end)
    end)
end)

0
why does this wpork iwilllandonmars 55 — 9y
0
because I change the parent of the stats. XToonLinkX123 580 — 9y
Ad
Log in to vote
-3
Answered by 9 years ago

Look back up at line 5, where you name the points(in the leaderstats model) as "Points". When referencing this, you have to use that name. In line 9, you look under player using plr, which is fine because that is a variable, then leaderstats, which is fine because the name is "leaderstats", but then you look for an object called "points", when the childs you are really looking for is "Points".

Long story short, capitalize points when you use it because the name you set it as is capitalized as well, so the script should be

plr.leaderstats.Points.Value = plr.leaderstats.Points.Value - 1

0
Still doesnt work... iwilllandonmars 55 — 9y

Answer this question