Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why won't this point giver work?

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

✓ Accepted answer
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)

1 comment

0

Oh, wow. Stupid mistake... Thanks for the help!

This discussion is preserved as it was. New answers, comments, and votes are closed.