0

# How to make if strenght ( in leaderboard ) = 100 then + 100 cash, and strenght reset to 0 ?

3 days ago

How to make if strenght ( in leaderboard ) = 100 then + 100 cash, and strenght reset to 0 ? - How to make that ? - PPJASk -best regards

0

Firstly we're of course making our leaderstats which I'm guessing you did already, just incase.

local Players = game:GetService("Players")
local Create = Instance.new

local Folder = Instance.new("Folder") --Creating a folder called leaderstats to store data.
Folder.Parent = player

local Strenght = Create("IntValue") --Creating a value thats gonna be used as strenght
Strenght.Parent = Folder
Strenght.Name = "Strenght"
Strenght.Value = 0

local Cash = Create("IntValue")--Here too, Cash instead.
Cash.Parent = Folder
Cash.Name = "Cash"
Cash.Value = 0
end)



Then of course, the checking and subtracting.

We'll create a function with 3 arguments, being the leaderstats folder, the strenght value, and the cash value.

Afterwards we'll check if the strenght value is higher or equal to 100. Then we're adding 100 cash onto the current cash value. Setting the strenght value back to 0.

local Subtract = function(leaderstats,strenght,cash)
if strenght.Value <= 100 then
cash.Value+=100
strenght.Value = 0
end
end


Of course, If you do not know how to connect these functions here's an example using a Remote Event.

Event.OnServerEvent:Connect(function(player)