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!
debounce
debounce = true 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 not debounce then return end debounce = false if player.Inventory.example.Value >= 10 then player.Inventory.example.Value = player.Inventory.example.Value - 10 --- value=value-10 money.Value = money.Value +100 debounce = true end end end)
lol try this i'm not the best at coding so please don't be mad at me if it doesn't work.