Hello community, this is a script of a Tool, that when you click on it gives Coins, the problem is that there is an error with this and the BackPack, when the Tool gives more than the backpack then it is equal to the value of the Tool. How do I do so that it does not put the value of the Tool, but the total of the backpack?
If the Tool gives 100 and
Backpack is 50, then the backpack will be 100/50.
Please help.
Starterpack - Tool - LocalScript:
local Debounce = false
local Tool = script.Parent
local Num = 100
local Player = game.Players.LocalPlayer
Tool.Activated:Connect(function()
if Debounce == false then
wait(0.5)
Debounce = true
game.ReplicatedStorage.Currencys.Tools.Basic:FireServer(Num)
if game.Players.LocalPlayer.Bag.Amount.Value >= game.Players.LocalPlayer.Bag.Max.Value then
game.Players.LocalPlayer.PlayerGui.CurrencyUI.MochilaLlenaFrame.Visible = true
end
wait(0.1)
Debounce = false
end
end)
Event Remote - Script:
game.ReplicatedStorage.Currencys.Tools.Basic.OnServerEvent:Connect(function(Player, Num)
if Player.Bag.Amount.Value < Player.Bag.Max.Value then
Player.Bag.Amount.Value = Player.Bag.Amount.Value + Num
end
end)
Image:
