CCCPaste

Pizza with Stocks

local PizzaNumber = 10

local PizzaBox = script.Parent

local Name = "Pizza"

local ClickDetector = Instance.new("ClickDetector", PizzaBox)
local Proximity = Instance.new("ProximityPrompt", PizzaBox)

local TextLabel = script.Parent.PizzaStocks.stocksLabel

TextLabel.Text = Name.." ["..PizzaNumber.." Stock]"

ClickDetector.MouseClick:Connect(function(player)
	TextLabel.Text = Name.." ["..PizzaNumber.." Stock]"

	PizzaNumber -= 1
	game.ServerStorage.Foods[Name]:Clone().Parent = player.Backpack
end)

while wait() do
	if PizzaNumber == 0 then
		PizzaBox.Transparency = 0.8
		PizzaBox.Pizza_Icon.Transparency = 0.8
		wait(1)
		break
	end
end

ClickDetector.MouseHoverEnter:Connect(function()
	if not script.Parent:FindFirstChild("SelectionBox") then
		local Selection = Instance.new("SelectionBox")
		Selection.Adornee = script.Parent
		Selection.Parent = script.Parent
		Selection.Color3 = Color3.new(1, 1, 1)
		Selection.Transparency = 0.8
	end
end)

ClickDetector.MouseHoverLeave:Connect(function()
	if script.Parent:FindFirstChild("SelectionBox") then
		script.Parent.SelectionBox:Destroy()
	end
end)

Proximity.Triggered:Connect(function(player)
	local PizzaBox = player.Character:FindFirstChild("PizzaBox")

	PizzaBox:Destroy()
	PizzaBox.Transparency = 0

end)