So pretty much, I have a leaderboard script so when you touch a brick named Robux, it will add +1 your Money score. But it doesn't seem to be working. Could you help me fix it?
Heres the script, btw
game.Players.PlayerAdded:connect(function(player) --We create a function that will execute when PlayerAdded fires.
local leaderstats = Instance.new("Model", player) --We insert an Model into the the new player (player)
leaderstats.Name = "leaderstats"
end) --closes function
game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("Model", player)
leaderstats.Name = "leaderstats"
local robux = Instance.new("IntValue", leaderstats) --We instance a new IntValue as a child of 'leaderstats'
money.Name = "Robux" --this is the name you want the leader-stat to be when it shows up in-game.
money.Value = 15 --this is the value of money the new player starts out with.
end)
game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("Model", player)
leaderstats.Name = "leaderstats"
local money = Instance.new("IntValue", leaderstats)
money.Name = "Money"
money.Value = 0
end)
while wait(5) do
for _,Player in pairs(game.Players:GetPlayers()) do
if Player:FindFirstChild("leaderstats") then
Player.leaderstats.Money.Value = Player.leaderstats.Money.Value +1
end
end
end
local brick = Workspace.Robux -- Store a reference to the brick.
function onTouch(part) -- The function that runs when the part is touched.
brick:remove()
Player.leaderstats.Money.Value = Player.leaderstats.Money.Value +1
end
brick.Touched:connect(onTouch) -- The line that connects the function to the event.

2 comments
Also the top part is more of just adding the leaderboard or other features. I just kept it incase you needed it or not.
You have lots of things wrong in your script. You even did "money.Name = "Robux