--Set up activated event.

InputHandler.WeaponActivated:Connect(function(TargetPos)
	if Equipped and Tool.Enabled then
		local NextRocket = RocketBuffer:PopItem()
		if NextRocket then
			local CurrentTime = tick()
			LastReloadTime = CurrentTime
			if CurrentAnimation then CurrentAnimation:Stop() end
			
			--Laucn the rocket.
			FireRocketEvent:FireServer()
			Tool.Enabled = false
			CurrentAnimation = AnimationPlayer:PlayAnimation("RocketLauncherFireAndReload")
			LaunchRocket(NextRocket,TargetPos)
			
			--Run the reload animation.
			CurrentHandRocket = Tool:FindFirstChild("HandRocket",true)
			if LocalReloadSound then
				LocalReloadSound:Play()
			end
			
			wait(ROCKET_RELOAD_WAIT_TO_SHOW_TIME)
			if LastReloadTime ~= CurrentTime then return end
			if CurrentHandRocket then
				CurrentHandRocket.Transparency = 0
				CurrentHandRocket.LocalTransparencyModifier = 0
			end
			wait(ROCKET_RELOAD_VISIBLE_TIME)
			if LastReloadTime ~= CurrentTime then return end
			if CurrentHandRocket then
				CurrentHandRocket.Transparency = 1
				CurrentHandRocket.LocalTransparencyModifier = 1
			end
		end
	end
end)
