Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you make the leaderstats not go below zero? [That is FE compatible]

Asked by
UW0tt 0
4 years ago

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?

0
Use your brain lol User#6546 35 — 4y
0
I don't have one, lol. UW0tt 0 — 4y
0
Buy a brain, lol. Fifkee 2017 — 4y
0
Can you post your script please? Vxpper 101 — 4y
0
Yes UW0tt 0 — 4y

1 answer

Log in to vote
0
Answered by
UW0tt 0
4 years ago
Edited 4 years ago

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

0
is there a script of where you are buying an item? If so could you post that as well? Vxpper 101 — 4y
0
Sure. UW0tt 0 — 4y
Ad

Answer this question