I've scripted for about a year but I've never seemed to be able to work with leader stats. I get a bunch of errors in the script when I try to make them purchase an item via click detector. Any fixes in errors?
Script: function onPlayerEntered(newPlayer) wait(.5) local stats = Instance.new("IntValue") stats.Name = "leaderstats"
local score = Instance.new("IntValue")
score.Name = "Money"
score.Value = 0
score.Parent = stats
stats.Parent = newPlayer
end
game.Players.ChildAdded:connect(onPlayerEntered)
script.Parent.ClickDetector.MouseClick:Connect(function(hit) local function buy(plr) local leaderstats = plr:FindFirstChild('leaderstats') if leaderstats then local cash = leaderstats:FindFirstChild('Money') if cash and cash.Value <= 50 then cash.Value = cash.Value-50 end end end end

4 comments
There's no leaderboard because the stats variable is an IntValue. It should be a folder.
put the code into a code block properly. Also, check the output for errors and tell us what they are
"game.Players.ChildAdded:Connect(onPlayerEntered) is really unreliable way to tell if the player joined. replace it with this "game.Players.PlayerAdded:Connect(OnPlayerEntered)"
Your code isn't running because you put it inside a function that was never called.