HowToRoblox

PurchaseHandler

Mar 4th, 2021
1,622
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local items = game.ReplicatedStorage:WaitForChild("Items")
  2.  
  3.  
  4. game.Players.PlayerAdded:Connect(function(plr)
  5.    
  6.    
  7.     local ls = Instance.new("Folder")
  8.     ls.Name = "leaderstats"
  9.     ls.Parent = plr
  10.    
  11.     local cash = Instance.new("IntValue")
  12.     cash.Name = "Cash"
  13.     cash.Value = 1000
  14.     cash.Parent = ls
  15. end)
  16.  
  17.  
  18. game.ReplicatedStorage:WaitForChild("OnItemBought").OnServerEvent:Connect(function(plr, itemBought)
  19.    
  20.     if itemBought and itemBought:IsA("Tool") and itemBought.Parent == items then
  21.        
  22.        
  23.         local cash = plr.leaderstats.Cash
  24.        
  25.         if cash.Value >= itemBought.ShopGuiInfo.Price.Value then
  26.            
  27.             cash.Value -= itemBought.ShopGuiInfo.Price.Value
  28.            
  29.             itemBought:Clone().Parent = plr.Backpack
  30.         end
  31.     end
  32. end)
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×