--Set up equipping and unequipping the tool.

Tool.Equipped:Connect(function()
	if not Equipped then
		Equipped = true
		
		CurrentCharacter = Tool.Parent
		CurrentPlayer = game.Players:GetPlayerFromCharacter(CurrentCharacter)
		EquipSound:Play()
		
		--Create the left hand rocket.
		local LeftGripAttachment = CurrentCharacter:FindFirstChild("LeftGripAttachment",true)
		if LeftGripAttachment then
			CurrentHandRocket = RocketCreator:CreateRocket(false)
			CurrentHandRocket.Name = "HandRocket"
			CurrentHandRocket.Transparency  = 1
			CurrentHandRocket.Parent = Tool
			
			local Weld = Instance.new("Weld")
			Weld.Part0 = LeftGripAttachment.Parent
			Weld.Part1 = CurrentHandRocket
			Weld.C0 = LeftGripAttachment.CFrame
			Weld.C1 = CFrame.Angles(0,math.pi,0)
			Weld.Parent = CurrentHandRocket
		end
		
		RocketBuffer:SetCurrentPlayer(CurrentPlayer)
	end
end)

Tool.Unequipped:Connect(function()
	if Equipped then
		Equipped = false
		
		CurrentCharacter = nil
		CurrentPlayer = nil
		EquipSound:Stop()
		if CurrentHandRocket then CurrentHandRocket:Destroy() end
		RocketBuffer:SetCurrentPlayer()
	end
end)
