Hey there biocommand here, I am working in some games and have the same problem with this, what I am trying to do is a brick that awards points when the player steps on it (Not player points) and it´s not working I used the one from roblox wiki and it might be outdated, heres the script:
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.Button.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 + 5 wait(20) enabled = true end end)
here´s the leaderboard if the problem is with that
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)
Also I put both with scripts, not local scripts.
There are two things wrong with your code:
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.Button.Touched:connect(function(hit) local p = game.Players:FindFirstChild(hit.Parent.Name) -- If there is not a player that has the name of a part's parent that touches button, then the script will error. Check if humanoid is in hit's parent. if pl and enabled == true then -- pl is undefined. You probably meant p. enabled = false p.leaderstats.Score.Value = p.leaderstats.Score.Value + 5 wait(20) enabled = true end end)
Hope I've helped!