Advertisement
Sungmingamerpro13

Stock and Give Item (Script)

Oct 28th, 2023
1,695
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 1.34 KB | None | 0 0
  1. local ServerStorage = game:GetService("ServerStorage")
  2.  
  3. local StockLabel = script.Parent.StockGui.stockLabel
  4. local Stock = 10
  5. local Cash = 25
  6.  
  7. local function GiveFood(player)
  8.  
  9.     if Stock >= 1 then
  10.         local ClonedFood = ServerStorage.ItemsFolder.WaterBottle:Clone()
  11.         ClonedFood.Parent = player.Backpack
  12.         Stock -= 1
  13.     elseif Stock <= 0 then
  14.         script.Parent.ClickDetector.MaxActivationDistance = 0
  15.         for i = 10,0,-1 do
  16.             StockLabel.Text = "STOCK IN"..i.." SECONDS"
  17.             wait(1)
  18.         end
  19.         StockLabel.Text = "WATERBOTTLES STOCK: "..Stock --- Change ItemName
  20.         Stock += Stock
  21.     end
  22. end
  23.  
  24. script.Parent.ClickDetector.MouseHoverEnter:Connect(function()
  25.     if not script.Parent:FindFirstChild("SelectionBox") then
  26.         local SelectionBox = Instance.new("SelectionBox")
  27.         SelectionBox.Adornee = script.Parent
  28.         SelectionBox.Parent = script.Parent
  29.         SelectionBox.Color3 = Color3.new(1, 1, 1)
  30.         SelectionBox.Transparency = 0.8
  31.     end
  32. end)
  33.  
  34. script.Parent.ClickDetector.MouseHoverLeave:Connect(function()
  35.     if script.Parent:FindFirstChild("SelectionBox") then
  36.         script.Parent.SelectionBox:Destroy()
  37.     end
  38. end)
  39.  
  40. script.Parent.ClickDetector.MouseClick:Connect(function(player)
  41.     StockLabel.Text = "WATERBOTTLES STOCK: "..Stock --- Change ItemName
  42.     if player.Coins.Value >= Cash then
  43.         player.Coins.Value = player.Coins.Value - Cash
  44.         GiveFood(player)
  45.     end
  46. end)
  47.  
Tags: Roblox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement