Make sure it's a serverscript. You can't give a player cash on the client side.
here is the code for the a normal script
01 | local sellitem = script.Parent.Parent.SellItem |
02 | local itemprice = script.Parent.Parent.ItemPrice |
03 | local sellbut = script.Parent |
05 | sellbut.MouseButton 1 Click:Connect( function (plr) |
06 | local inventory = plr:WaitForChild( "Inventory" ) |
07 | local leaders = plr:WaitForChild( "leaderstats" ) |
08 | local money = leaders:WaitForChild( "Money" ) |
09 | local backpack = inventory:FindFirstChild( "BackPack" ) |
10 | if sellitem.Text = = "Coal" and inventory.Coal.Value > = 1 then |
11 | local nice = inventory.Coal.Value * 10 |
12 | money.Value = money.Value + nice |
13 | backpack.Value = backpack.Value - inventory.Coal.Value |
14 | inventory.Coal.Value = inventory.Coal.Value - inventory.Coal.Value |
15 | elseif sellitem.Text = = "Gold Ore" and inventory.GoldOre.Value > = 1 then |
16 | local nice = inventory.GoldOre.Value * 100 |
17 | money.Value = money.Value + nice |
18 | backpack.Value = backpack.Value - inventory.GoldOre.Value |
19 | inventory.GoldOre.Value = inventory.GoldOre.Value - inventory.GoldOre.Value |
20 | elseif sellitem.Text = = "Iron Ore" and inventory.IronOre.Value > = 1 then |
21 | local nice = inventory.IronOre.Value * 50 |
22 | money.Value = money.Value + nice |
23 | backpack.Value = backpack.Value - inventory.IronOre.Value |
24 | inventory.IronOre.Value = inventory.IronOre.Value - inventory.IronOre.Value |
If you need more help Dm me on discord cancle5#0035