Upscalefanatic3

(Roblox) Sell Script [Learners]

Apr 3rd, 2020
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Sells all items and gives gold
  2. local sellPart = script.Parent
  3.  
  4.  
  5. local function sellItems(playerItems, playerGold)
  6.     local totalSell = playerItems.Value * 100
  7.    
  8.     playerGold.Value = playerGold.Value + totalSell
  9.    
  10.     playerItems.Value = 0
  11.    
  12. end
  13.  
  14.  
  15. local function onTouch(partTouched)
  16.     local character = partTouched.Parent
  17.     local humanoid = character:FindFirstChildWhichIsA("Humanoid")
  18.    
  19.     if humanoid then
  20.         local player = game.Players:GetPlayerFromCharacter(humanoid.Parent)
  21.        
  22.         local playerStats = player:FindFirstChild("leaderstats")
  23.        
  24.         --Get the player's items + money
  25.         local playerItems = playerStats:FindFirstChild("Items")
  26.         local playerGold = playerStats:FindFirstChild("Gold")
  27.        
  28.         print("A player has entered")
  29.         sellItems(playerItems, playerGold)
  30.     end
  31. end
  32.  
  33.  
  34. sellPart.Touched:Connect(onTouch)
Add Comment
Please, Sign In to add comment