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