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!
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)