Advertisement
KashTheKingYT

Buy Items Script

Aug 23rd, 2021
2,554
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.52 KB | None | 0 0
  1. local rs = game.ReplicatedStorage
  2. local buyItem = rs.BuyItem
  3. local items = game.ServerStorage.Items
  4. local itemsInfo = game.ServerStorage.ItemsInfo
  5.  
  6. buyItem.OnServerEvent:Connect(function(plr, itemName)
  7.     local item = items:FindFirstChild(itemName)
  8.     local price = itemsInfo:FindFirstChild(itemName).Value
  9.    
  10.     local plrMoney = plr:FindFirstChild("leaderstats"):FindFirstChild("Money")
  11.    
  12.     if plrMoney.Value - price >= 0 then
  13.         plrMoney.Value -= price
  14.         local newItem = item:Clone()
  15.         newItem.Parent = plr.Backpack
  16.     end
  17. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement