I have a system that let's you pick up a part and gives you a folder with the value of the item inside, I try to make a button to delete a specific number of the item (the intValue)... let's say 10, it will delete 10 until I reach the negatives how would I go about making it only take 10 from... let's say if the int value is 50? I also try to give the player money for the amount but it just gives them like 20,000 money when I try to give them only 100. I tried this:
local ITEM = game.ReplicatedStorage.Folder:WaitForChild("Event")
ITEM.OnServerEvent:Connect(function(player)
----
local stats = player:WaitForChild("leaderstats")
local money = stats:FindFirstChild("Money")
---
if player.Inventory:FindFirstChild("example") then
if player.Inventory.example.Value >= 10 then
player.Inventory.example.Value = player.Inventory.example.Value - 10 --- value=value-10
money.Value = money.Value +100
end
end
end)
What am I doing wrong? Also this is in a server script, I am using an event to trigger it from a local script, os it fine to put this in a server script? Or a local script?
Thanks!

4 comments
You should be doing this in a server script, that's where all player stat changing should be handled, but you also have to add checks to see if the player has earnt the money (exploiters can fire remote events whenever they want)
This code should work I think. Did you put a debounce on the click so that the code does not run twice at once?
The fire event*
I dont understand how to add a debounce to a click script, could anyone share an example? Im stumped. I am also working on an exploit proof system.