for j, l in pairs(button:GetChildren()) do if l.BuyButton.Transparency ~= 1 then l.BuyButton.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) local money = player.leaderstats.Money.Value local cost = l.Cost.Value if money >= cost then money = money - cost print(money) -- when I print it out, the player's money got subtracted but not in the leaderstats for i, v in pairs(FurnitureTable) do if v.Name == l.Purchase.Value then v.Parent = items end end end end) end end
hello, i made a purchase script where when a player touched a button it will subtract the player's money and the item will be purchased. But, the player's money doesn't get subtracted for a reason.
Try This,
if money >= cost then money -= cost print(money)
By doing...
money = money - cost
you are setting the variable 'money' to the sum of 'money - cost'
Using
money -= cost
will subtract the value of the IntValue from leaderstats.
Hope this helps!