My value will continue to go down! Help please?
Asked by
6 years ago Edited 6 years ago
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:
01 | local ITEM = game.ReplicatedStorage.Folder:WaitForChild( "Event" ) |
02 | ITEM.OnServerEvent:Connect( function (player) |
04 | local stats = player:WaitForChild( "leaderstats" ) |
05 | local money = stats:FindFirstChild( "Money" ) |
07 | if player.Inventory:FindFirstChild( "example" ) then |
09 | if player.Inventory.example.Value > = 10 then |
10 | player.Inventory.example.Value = player.Inventory.example.Value - 10 |
11 | money.Value = money.Value + 100 |
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!