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

Why won't this point giver work?

Asked by 10 years ago

Hey there! So, I am trying to make a brick that adds points to a player's leaderboard if they touch it. The brick is named PointGiver, and I put the following script into Workspace:

local enabled = true

game.Players.PlayerAdded:connect(function(player)
    local leader, score = Instance.new('IntValue', player), Instance.new('IntValue')
    leader.Name = 'leaderstats'
    score.Name = 'Score'
    score.Parent = leader
end)

Workspace.PointGiver.Touched:connect(function(hit)
    local p = game.Players:FindFirstChild(hit.Parent.Name)
    if pl and enabled == true then
        enabled = false
        p.leaderstats.Score.Value = p.leaderstats.Score.Value + 50
        wait()
        enabled = true
    end
end)

It's not working though. Can anyone figure out my problem? Thanks in advance!

1 answer

Log in to vote
1
Answered by
jav2612 180
10 years ago
local enabled = true

game.Players.PlayerAdded:connect(function(player)
    local leader, score = Instance.new('IntValue', player), Instance.new('IntValue')
    leader.Name = 'leaderstats'
    score.Name = 'Score'
    score.Parent = leader
end)

Workspace.PointGiver.Touched:connect(function(hit)
    local p = game.Players:FindFirstChild(hit.Parent.Name)
    if p and enabled == true then -- it seems you added an extra "l" here after the p
        enabled = false
        p.leaderstats.Score.Value = p.leaderstats.Score.Value + 50
        wait()
        enabled = true
    end
end)
0
Oh, wow. Stupid mistake... Thanks for the help! dpark19285 375 — 10y
Ad

Answer this question