I have this problem that when you buy something. You can keep buying, even when it is in the negatives. How do I stop this?
I forgot to post the script. Here you go. (This doesn't work anymore because of FE I am guessing)
function CheckPoints(Points) if Points.Value < 0 then Points.Value = 0 end end) game.Players.PlayerAdded:connect(function(Player) --anonymous function local ls = Instance.new("Configuration", Player) ls.Name = "leaderstats" local Points = Instance.new("IntValue", ls) -- classname, parent Points.Name = "Money" Points.Changed:connect(function() CheckPoints(Points) end) end)
EDIT: This is the script of when you click a button, then a certain amount of money gets taken away from your balance (I hired someone to do this):
script.Parent.ClickDetector.MouseClick:connect(function(player) local players = game.Players:FindFirstChild(player.Name) local clicks = players:FindFirstChild("leaderstats")["Money"] clicks.Value = clicks.Value -0.1 end)
This is the leaderboard stats itself:
local ds = game:GetService("DataStoreService"):GetDataStore("stats") local stats={"Money"} game.Players.PlayerAdded:connect(function(plyr) local a=Instance.new("NumberValue") a.Parent=plyr a.Name="leaderstats" for i=1,#stats do local Wins=Instance.new("NumberValue") Wins.Parent=a Wins.Value=0 Wins.Name=stats[i] end local child=plyr.leaderstats:GetChildren() for i=1, #child do child[i].Value=ds:GetAsync(plyr.userId..child[i].Name) end end) game.Players.PlayerRemoving:connect(function(plyr) local child=plyr.leaderstats:GetChildren() for i=1, #child do child[i].Value=ds:SetAsync(plyr.userId..child[i].Name,child[i].Value) end end)
I hope this helps