--the click

script.Parent.ClickDetector.MouseClick:connect(function(player)
	if ready == true then
		ready = false
		local tool = machine.IceCream:clone()
		local Plate = script.Parent.Parent.Plate
		local handl = script.Parent.Parent.Content.Handle:clone()
		
		handl.Parent = storage
		tool.Parent =  storage
		handl.Position = Vector3.new(Plate.Position.X,Plate.Position.Y +0.6,Plate.Position.Z)
		machine.Who.Value = player.Name
		machine.Target.Text = ""..player.Name..""
		script.Parent.ClickDetector.MaxActivationDistance = 0
		coverdown()
		menuoneappear()
		
			for _,one in pairs(machine.ToppingsOne:GetChildren()) do
				if one:IsA("TextButton") then
					one.MouseButton1Down:connect(function()
					local ice = script.Parent.Parent.Ice[one.Name]:clone()
					ice.Parent = tool
					ice.CFrame = CFrame.new(Vector3.new(handl.Position.X+0.025,handl.Position.Y+0.15,handl.Position.Z))
					menuonedisappear()
					menutwoappear()
					
					for _,two in pairs(machine.ToppingsTwo:GetChildren()) do
						if two:IsA("TextButton") then
							two.MouseButton1Down:connect(function()
							local ice = script.Parent.Parent.Ice[two.Name]:clone()
							ice.Parent = tool
							ice.CFrame = CFrame.new(Vector3.new(handl.Position.X+0.025,handl.Position.Y+0.35,handl.Position.Z))
							menutwodisappear()
							handl.Parent = tool
							tool.Enabled = true
							tool.Weld.Disabled = false
							tool.IceScript.Disabled = false
							tool.Parent = game.Players[machine.Who.Value].Backpack
							for _,parts in pairs(tool:GetChildren()) do
								if parts:IsA("Part") then
								parts.Anchored = false
								end
							end
							wait()
							machine.Who.Value = ""
							machine.Target.Text = ""
							script.Parent.ClickDetector.MaxActivationDistance = 10
							coverup()
							script.Fixer.Disabled = false
						end)
					end
				end					
					end)
				end
			end
		wait(5)
	ready = true
	end
end)
